赞
踩
auth.js:
import Cookies from 'js-cookie'
const TokenKey = 'vue_admin_template_token'
const auth = {};
auth.getToken = function() {
return Cookies.get(TokenKey)
}
auth.setToken = function(token) {
return Cookies.set(TokenKey, token)
}
auth.removeToken = function() {
return Cookies.remove(TokenKey)
}
export default auth;
全局导入方法:
import auth from './auth'
Vue.prototype.$authUser = auth;
局部引用方法:
this.$authUser.removeToken();
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。