美文网首页
vue-cli 快速构建项目

vue-cli 快速构建项目

作者: 冰哲 | 来源:发表于2017-03-25 11:38 被阅读0次

使用方式(shell命令):

npm install -g vue-cli
vue init webpack projectname
cd projectname
npm install
npm run dev

通过上述几个步骤可以快速构建vue.js项目。
其实就是从Github上的vuejs-templates上拉取代码,安装npm依赖,建立一个简单的npm任务。
完成之后的样子:

Paste_Image.png

官方模版

还有其他的模版可以使用,使用下面的命令
vue init <template-name> <project-name>
vue list 可以查看所有可用模版

Paste_Image.png

搭建好生成的页面

Paste_Image.png

打包上线

自己的项目文件都需要放在src文件夹下。
项目开发完成后可以用npm run build来打包,打包完成后会生出dist文件夹,dist文件夹放到服务器上就可以了。

Paste_Image.png

注意下打包路径,可以在config>index.js修改下

Paste_Image.png

是因为打包之后,外部引入 js 和 css 文件时,如果路径以 ' / ' 开头,在本地是无法找到对应文件的(服务器上没问题)。所以如果需要在本地打开打包后的文件,就得修改文件路径。

相关文章

网友评论

      本文标题:vue-cli 快速构建项目

      本文链接:https://www.haomeiwen.com/subject/juxcottx.html