1,安装 vue init webpack moyooweb moyooweb是文件名称
2,进入 moyooweb文件安装 npm i element-ui -S
3,npm run dev自动打开浏览器 autoOpenBrowser: true,
4,配置element 在 main.js 中写入以下内容:
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
5,配置路由跳转
mode: 'history', base: '/moyooweb/',
修改config下的index.js
6,安装sass 配置sass
cnpm install --save-dev sass-loader@7.3.1
cnpm install --save-dev node-sass
在build文件夹下的webpack.base.conf.js的rules里面添加配置
{test:/\.sass$/,loaders:['style','css','sass']}
7,vue cookie 使用 方法 this.getCookie('type') 复制代码放入main.js里
Vue.prototype.setCookie = function (key, value, time = 1, time_format = 'd') {
let exp = new Date()
let _time = 0
switch (time_format) {
case 'y':// y year
_time = time * 365 * 24 * 60 * 60 * 1000
break
case 'm':// m month
_time = time * 30 * 24 * 60 * 60 * 1000
break
case 'd':// d day
_time = time * 24 * 60 * 60 * 1000
break
case 'h':// h hour
_time = time * 60 * 60 * 1000
break
case 'min':// min minute
_time = time * 60 * 1000
break
default:// s second
_time = time * 1000
}
exp.setTime(exp.getTime() + _time)
document.cookie = key + "=" + escape(value) + ";expires=" + exp.toGMTString()
}
Vue.prototype.getCookie = function (key) {
let arr, reg = new RegExp("(^| )" + key + "=([^;]*)(;|$)")
if (arr = document.cookie.match(reg))
return unescape(arr[2])
else
return null
}
Vue.prototype.delCookie = function (key) {
let exp = new Date()
exp.setTime(exp.getTime() - 1)
let cval = this.getCookie(key)
if (cval != null)
document.cookie = key + "=" + cval + ";expires=" + exp.toGMTString()
}