[email protected] 从零开始搭建-配置-打包-路径配置

1.查看 node和npm是不是已经安装好命令:node -v npm -v (没有安装的先安装环境);
2.npm install -g cnpm --registry=https://registry.npm.taobao.org (安装国内的淘宝镜像文件,后面的安装npm可以全部改为cnpm)
3.安装 vue-cli 脚手架
1、cnpm install -g vue(全局安装vue)
2、cnpm install -g vue-cli //检测是否安装成功 vue --version
4. 安装 webpack cnpm install -g webpack
[email protected] 从零开始搭建-配置-打包-路径配置
5.cd 你的运行目录
6.新建基于webpack的vue项目 vue init webpack vuedemo
7.进入项目目录 cd vuedemo
8.安装依赖 cnpm install
9.运行项目 cnpm run dev
10.发布项目 cnpm run build

看页面是否要缓存可以通过keep-alive 做缓存,
在app.vue中配置
[email protected] 从零开始搭建-配置-打包-路径配置
{
path: ‘/helloWorld’,
name: ‘HelloWorld’,
component: HelloWorld,
meta: {
keepAlive: true, // 需要被缓存,
title:‘首页’
}
},

**

一. 路由引入的两种方式,和头部title页面标题设置

**
[email protected] 从零开始搭建-配置-打包-路径配置
{
path: ‘/helloWorld’,
name: ‘HelloWorld’,
component: HelloWorld,
meta: {
keepAlive: true, // 需要被缓存,
title:‘首页’
}
},
{
// 这种形式引入组件就不用在上边引入,然后再使用了,@是项目新建的时候就配好的src路径,如需修改去webpack.base中修改就行
path: ‘/’,//测试时为了方便可以把你当前开发的页面设置为默认页面,改的是path,和上边的区别就是,上边只需要改componen就行,但是这个页面会很长
name: ‘home’,
component: resolve => require([’@/pages/index/home’], resolve),
meta: {
keepAlive: true, // 需要被缓存,
title:‘首页’
}
},
页面的title设置,
[email protected] 从零开始搭建-配置-打包-路径配置
要安装插件 vue-wechat-title
[email protected] 从零开始搭建-配置-打包-路径配置
或者你有统一的头部组件
[email protected] 从零开始搭建-配置-打包-路径配置