在已经安装有node、npm环境的机器里,npm install -g vue-cli
,寝化项目vue init webpack vuedemo
。
修改config/index.js文件的dev里的host,localhost => 0.0.0.0
,这是因为项目是跑在虚拟机里的,使用localhost+port是访问不了的。
路由写成懒加载形式
routes: [
{
path: '/',
name: 'HelloWorld',
component: r => require(['@/components/HelloWorld'], r)
},
{
path: '/test',
name: 'test',
component: r => require(['@/components/Test'], r)
}
]
在build/build.js修改chunks: false => chunks: true
,这样配置是为了实现懒加载文件