vue1.怎么初始化一个项目

Vue 300问

1.怎么基于webpack初始化一个项目

安装node (npm)
安装webpack

安装vue-cli (脚手架)

npm install vue-cli -g
安装后可以使用vue 命令

脚手架命令

  • 1.查看版本
vue -V

V是大写

  • 2.初始化项目

vue init 模板 [项目命名]
模板 webpack webpack-simple

不写项目名意味着在当前文件夹下初始化项目
Generate project in current directory? Y

注意: Sorry, name can no longer contain capital letters.
文件名字不可以用大写
http://www.jianshu.com/p/2769efeaa10a

demo

$ vue init webpack

? Generate project in current directory? Yes
  This will install Vue 2.x version of the template.

  For Vue 1.x use: vue init webpack#1.0

? Project name app
? Project description this is app
? Author king
? Vue build standalone
? Install vue-router? Yes
? Use ESLint to lint your code? No
? Setup unit tests with Karma + Mocha? No
? Setup e2e tests with Nightwatch? No

   vue-cli · Generated "Vue".

   To get started:

     npm install
     npm run dev

   Documentation can be found at https://vuejs-templates.github.io/webpack

目录结构

├─build
│ build.js
│ check-versions.js
│ dev-client.js
│ dev-server.js
│ utils.js
│ vue-loader.conf.js
│ webpack.base.conf.js
│ webpack.dev.conf.js
│ webpack.prod.conf.js

├─config
│ dev.env.js
│ index.js
│ prod.env.js

├─src
│ │ App.vue
│ │ main.js
│ │
│ ├─assets
│ │ logo.png
│ │
│ ├─components
│ │ Hello.vue
│ │
│ └─router
│ index.js

└─static
| .gitkeep
│ .babelrc
│ .editorconfig
│ .gitignore
│ .postcssrc.js
│ index.html
│ package.json
│ README.md

启动项目

  npm install
  npm run dev

posted @ 2017-09-15 17:24  oneboi  阅读(925)  评论(0)    收藏  举报