vue-cli项目生成

安装vue-cli

C:Usersfei>npm install -g vue-cli
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coff
eescript" (no hyphen)
D:
odes
ode_cachevue-init -> D:
odes
ode_cache
ode_modulesvue-cliinvue
-init
D:
odes
ode_cachevue -> D:
odes
ode_cache
ode_modulesvue-cliinvue
D:
odes
ode_cachevue-list -> D:
odes
ode_cache
ode_modulesvue-cliinvue
-list
+ vue-cli@2.9.6
added 239 packages in 79.481s

相关命令

  查看版本信息和帮助信息

C:Usersfei>vue -V
2.9.6

C:Usersfei>vue --help
Usage: vue <command> [options]

Options:
  -V, --version  output the version number
  -h, --help     output usage information

Commands:
  init           generate a new project from a template
  list           list available official templates
  build          prototype a new project
  create         (for v3 warning only)
  help [cmd]     display help for [cmd]

  查看模板信息

C:Usersfei>vue list

  Available official templates:

  ★  browserify - A full-featured Browserify + vueify setup with hot-reload, li
nting & unit testing.
  ★  browserify-simple - A simple Browserify + vueify setup for quick prototypi
ng.
  ★  pwa - PWA template for vue-cli based on the webpack template
  ★  simple - The simplest possible Vue setup in a single HTML file
  ★  webpack - A full-featured Webpack + vue-loader setup with hot reload, lint
ing, testing & css extraction.
  ★  webpack-simple - A simple Webpack + vue-loader setup for quick prototyping
.
# 切换到指定目录

C:Usersfei>cd E:前端vuevue学习第一个vue-cli项目

C:Usersfei>e:

E:前端vuevue学习第一个vue-cli项目>

  项目生成

E:前端vuevue学习第一个vue-cli项目>vue init webpack-simple myProject

? Project name 01
? Project description A Vue.js project
? Author 张亚飞 <1271570224@qq.com>
? License MIT
? Use sass? No

   vue-cli · Generated "myProject".

   To get started:

     cd myProject
     npm install
     npm run dev 

 如果报错

> cross-env NODE_ENV=development webpack-dev-server --open --hot

'webpack-dev-server' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
events.js:167
      throw er; // Unhandled 'error' event
      ^

解决方案

npm install webpack-cli@3.0.0 -g 

vue开源项目汇总

https://github.com/opendigg/awesome-github-vue

  

原文地址:https://www.cnblogs.com/zhangyafei/p/10276385.html