Vue Router 介绍:https://router.vuejs.org/zh/
快速搭建和安装Vue.js项目:学习记录。
$cnpm install vue # 安装 vue
$cnpm install --global vue-cli #全局安装vue-cli
$ vue init webpack vue-project1 # 进行一些配置,输入项目名,其余默认回车
? Project name vue0314
? Project description A Vue.js project
? Author too-hoo <[email protected]>
? Vue build standalone #打包方式
? Install vue-router? Yes
? Use ESLint to lint your code? Yes #使用ESLint规范代码
? Pick an ESLint preset Standard
? Set up unit tests Yes #单元测试
? Pick a test runner jest
? Setup e2e tests with Nightwatch? Yes
? Should we run `npm install` for you after the project has been created? (recommended) npm
vue-cli · Generated "vue-project1".
# Installing project dependencies ...
# ========================
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: Switch to the `bfj` package for fixes and new features!
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated [email protected]: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
> [email protected] install /home/toohoo/learnVue/ROW/vue-project1/node_modules/chromedriver
> node install.js
Current existing ChromeDriver binary is unavailable, proceding with download and extraction.
Downloading from file: https://chromedriver.storage.googleapis.com/2.46/chromedriver_linux64.zip
Saving to file: /tmp/2.46/chromedriver/chromedriver_linux64.zip
Received 782K...
Received 1568K...
Received 2352K...
Received 3136K...
Received 3920K...
Received 4704K...
Received 5277K total.
Extracting zip contents
Copying to target path /home/toohoo/learnVue/ROW/vue-project1/node_modules/chromedriver/lib/chromedriver
Fixing file permissions
Done. ChromeDriver binary available at /home/toohoo/learnVue/ROW/vue-project1/node_modules/chromedriver/lib/chromedriver/chromedriver
> [email protected] postinstall /home/toohoo/learnVue/ROW/vue-project1/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
added 1590 packages from 1090 contributors and audited 30843 packages in 249.962s
found 73 vulnerabilities (66 low, 1 moderate, 5 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for details
Running eslint --fix to comply with chosen preset rules...
# ========================
> [email protected] lint /home/toohoo/learnVue/ROW/vue-project1
> eslint --ext .js,.vue src test/unit test/e2e/specs "--fix"
# Project initialization finished!
# ========================
To get started:
cd vue-project1
npm run dev
Documentation can be found at https://vuejs-templates.github.io/webpack
搭建项目完成,进入目录安装和访问测试:
toohoo@ubuntu:~/learnVue/ROW$ cd vue-project1/ # 进入工程目录
toohoo@ubuntu:~/learnVue/ROW/vue-project1$ ls
build config index.html node_modules package.json package-lock.json README.md src static test
toohoo@ubuntu:~/learnVue/ROW/vue-project1$ cnpm install #开始安装
✔ Installed 58 packages
✔ Linked 0 latest versions
✔ Run 0 scripts
✔ All packages installed (used 143ms(network 140ms), speed 0B/s, json 0(0B), tarball 0B)
toohoo@ubuntu:~/learnVue/ROW/vue-project1$ ls
build config index.html node_modules package.json package-lock.json README.md src static test
toohoo@ubuntu:~/learnVue/ROW/vue-project1$ cnpm run dev #运行工程
> [email protected] dev /home/toohoo/learnVue/ROW/vue-project1
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
12% building modules 21/28 modules 7 active ...roject1/src/components/HelloWorld.vue{ parser: "babylon" } is deprecated; we now treat it as { parser: "babel" }.
95% emitting
DONE Compiled successfully in 22027ms 10:36:17 AM
I Your application is running here: http://localhost:8080