【发布时间】:2018-11-15 10:56:38
【问题描述】:
我正在尝试 laravel vue 应用中的 vue cook 插件,我就是这样做的
<template>
<div class="tranbg" v-if="first">
<div>hello</div>
<button @click="turnOff">ok</button>
</div>
</template>
<script>
export default {
data(){
return {
first: true
}
},
computed(){
if (this.$cookie.get('firstvisit') == 'visited') {
this.first = false
}
},
methods:{
turnOff(){
this.first = false
this.$cookie.set('firstvisit', 'visited', 30000); // 30,000 days
}
}
}
</script>
我的 app.js
import VueCookies from '../../../node_modules/vue-cookies'
Vue.use(VueCookies)
const app = new Vue({
el: '#app',
});
收到错误 app.js?v=226:103199 Uncaught TypeError: Cannot read property 'set' of undefined 当我单击按钮时
【问题讨论】: