1,安装node.js下载地址:https://nodejs.org/en/ 下载LTS版本
windows +r打开 输入指令cmd
输入node -v/npm -v分别查看是否有版本,有则是安装完成!
2,由于npm是国外服务器所以下载要求的网速极高,我们使用淘宝镜像cnpm来下载我们的vue.js,
请输入命令:npm install -g cnpm --registry=http://registry.npm.taobao.org;(下载)
3,下载安装vue-cli脚手框建工具
在命令行中npm install -g vue-cli等待安装完成后输入vue -V可查看版本,目前稳定版本2.9.6
4,创建项目:~初始化项目cd 输入你要把项目放在哪里的目录desktop(桌面)
~vue init webpack pname(你的项目名字);
~? Project description (A Vue.js project) vue-cli新建项目(项目描述)
~? Author (xhdx <zhuming3834@sina.com>) ;zhuming3834@sina.com(项目作者)
~? 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
这里选择Runtime + Compiler: recommended for most users;
~? Install vue-router? (Y/n) y 是否使用vue-router,这里根据需求选择;
~? Use ESLint to lint your code? (Y/n) y 是否使用ESLint,这里根据需求选择;
~? Pick an ESLint preset (Use arrow keys)❯ Standard (https://github.com/feross/standard)
Airbnb (https://github.com/airbnb/javascript) none (configure it yourself) 这里选择Standard (https://github.com/feross/standard)
~? Setup unit tests with Karma + Mocha? (Y/n) n 是否需要单元测试,这里根据需求选择;
~Setup e2e tests with Nightwatch? (Y/n) n是否需要单元测试,这里根据需求选择;
~cd pname(项目目录)
~npm install安装依赖
~npm run dev 本地运行项目
5,文件目录的
(1)build:项目构建(wepack)相关代码。
(2)config:配置目录,包括端口号等。我们初学者可以使用默认的。
(3)node_modules:npm加载的项目依赖模块
(4)src:这里我们要开发的目录,基本上要做的事情都在这个目录里。里面包含了几个目录及其文件;
assets:放置一些图片,如logo等。
components是:目录里面放了一个组件文件,可以不用。
App.vue:项目入口文件,我们也可以直接将组件写在这里,而不是components目录。
main.js:项目的核心文件。
(5)static:静态资源目录,如图片,字体等。
(6)test 初始测试目录,可删除
(7)index.html 首页的入口文件,你可以添加一些meta信息或代码统计代码啥的。
(8)package.json项目配置文件。
(9)README.md项目的说明文档,markdown格式。
6,在VScode中的直接引用Vue:
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
Vscode里推荐的扩展无脑下,总能用的上。