[英]vue-session: Uncaught TypeError: Cannot set properties of undefined (setting '$session')
I just install vue-session plugin to my project(vue 3 with Vite), with the setup like below:我只是将 vue-session 插件安装到我的项目(带 Vite 的 vue 3)中,设置如下:
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-session
Vue.prototype.$session = { <--this line
flash: {
parent: function(){
return Vue.prototype.$session;
},
get: function(key){
....
vue-cookies vue-cookies
var VueCookies = {
// install of Vue
install: function (Vue) {
Vue.prototype.$cookies = this;
Vue.$cookies = this;
},
Can somebody help a JS newbie?有人可以帮助 JS 新手吗?
It sa Vue2 plugin.它是一个 Vue2 插件。 It wont works with Vue3.它不适用于 Vue3。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.