1、vue-cli新建模板项目
准备
在使用vue-cli新建项目前。请确保你已经安装了Node.js,vue和vue-cli。
步骤:
cd 目录(要把项目放在哪个目录)
vue init webpack pname(你的项目名字)
Project description (A Vue.js project) vue-cli新建项目(项目描述)
Author (作者)
Vue build
❯ Runtime + Compiler: recommended for most users
Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere
Install vue-router? (Y/n) 是否使用 vue-router,Y
Use ESLint to lint your code? (Y/n) 是否使用ESLint,Y
Pick an ESLint preset (Use arrow keys)
❯ Standard (https://github.com/feross/standard)
Airbnb (https://github.com/airbnb/javascript) none (configure it yourself)
Setup unit tests with Karma + Mocha? (Y/n) 是否需要单元测试,N
Setup e2e tests with Nightwatch? (Y/n) 是否需要单元测试,N
-
Should we run `npm install` for you after the project has been created? (recom mended) ❯ Yes, use NPM 自动运行 npm install 安装依赖 Yes, use Yarn No, I will handle that myself
npm run dev 本地运行
结果
浏览器打开 http://localhost:8080