Reputation: 21
I just install vue-session plugin to my project(vue 3 with Vite), with the setup like below:
import { createApp } from 'vue'
import App from './App.vue'
import VueSession from 'vue-session' <---
import router from './router.js' //
createApp(App).use(router).use(VueSession).mount('#app')
But when I tried to reload the page, it shows:
Uncaught TypeError: Cannot set properties of undefined (setting '$session')
at Object.VueSession.install (index.js:13:19)
at Object.use (runtime-core.esm-bundler.js:3808:28)
at main.js?t=1648710456054:7:28
The other plugin also show same error:
Uncaught TypeError: Cannot set properties of undefined (setting '$cookies')
at Object.install (vue-cookies.js:22:21)
at Object.use (runtime-core.esm-bundler.js:3808:28)
at main.js?t=1648712611253:7:28
Source: vue-session
Vue.prototype.$session = { <--this line
flash: {
parent: function(){
return Vue.prototype.$session;
},
get: function(key){
....
vue-cookies
var VueCookies = {
// install of Vue
install: function (Vue) {
Vue.prototype.$cookies = this;
Vue.$cookies = this;
},
Can somebody help a JS newbie?
Upvotes: 1
Views: 1836