【发布时间】:2017-07-12 12:51:11
【问题描述】:
我在路由器 index.js 中使用此代码作为 Vuejs 中的登录路由
if (this.$cookie.get('token')) {
next('/dashboard')
}
但我得到的是未定义的
【问题讨论】:
-
你必须包含/引用插件 vue-cookie 吗?还要检查你是否有 $cookie 对象,然后获取。
-
我已经包含 vue-cookie
-
如何检查 $cookie 对象,如果它不存在,那么如何包含它
-
你告诉你的 vue 使用插件 VueCookie 吗?像 Vue.use(VueCookie)。你可以检查使用 if(this.$cookie){ 'do some cookie things here' }else{ 'no cookie here'}
-
我用过 vue.use(VueCookie)
标签: javascript authentication cookies vue.js token