Vue CLI
Command-Line Interface,命令行界面,俗称脚手架。使用vue-cli可以快速搭建Vue开发环境以及webpack配置.
Vue脚手架使用前提:Node,Webpack.
使用
1.全局安装Vue脚手架:npm install -g @vue/cli(国内可以使用淘宝npm镜像使用cnpm代替npm。命令:npm install -g cnpm --registry=https://registry.npm.taobao.org )
2.步骤1默认安装的是脚手架1,所以要使用脚手架2的话需要拉取脚手架2模板:npm install -g @vue/cli-init
3.Vue ClI2初始化项目:vue init webpack my-project;Vue ClI3及以上初始化项目:vue create my-project
4.新建项目时一些选项:Project name(项目名称),Project description(项目描述),Author(作者),vue-router(vue全家桶有:VueCore+vue-router+vuex),ESLint(代码规范),unit tests(单元测试),e2e tests(end to end tests ,端到端测试)
注意:开发时使用runtime-only,性能更高且代码量更少。
Vue CLI2详解
创建项目选项详解
目录详解
run-time-complier和run-time-only的区别
run-time-complier:template->ast(虚拟语法树)->render->virsual-dom->真实dom(UI)
run-time-only:render->vdom->UI
1.run-time-only性能更高。2.run-time-only需要的源代码量更少
更多时候选择run-time-only