简体   繁体   English

vue-session: Uncaught TypeError: 无法设置未定义的属性(设置'$session')

[英]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.

相关问题 Nuxtjs Vue会话-无法读取未定义的属性“出口” - Nuxtjs Vue-session - Cannot read property 'exits' of undefined 未捕获的类型错误:无法设置未定义的属性(设置“渲染”) - Uncaught TypeError: Cannot set properties of undefined (setting 'render') 未捕获的类型错误:无法设置未定义的属性(设置“isSubcon”) - Uncaught TypeError: Cannot set properties of undefined (setting 'isSubcon') 未捕获的类型错误:无法设置未定义的属性(设置“全名”) - Uncaught TypeError: Cannot set properties of undefined (setting 'full_name') 未捕获的类型错误:无法设置未定义的属性(设置“innerHTML”) - Uncaught TypeError: Cannot set properties of undefined (setting 'innerHTML') TypeError:无法在 Vue 中设置未定义的属性(设置“消息”) - TypeError: Cannot set properties of undefined (setting 'message') in Vue 对于 onclick 中的 event.target - “Uncaught TypeError TypeError:无法设置未定义的属性(设置‘值’)” - For event.target in onclick - "Uncaught TypeError TypeError: Cannot set properties of undefined (setting 'value')" Javascript 上的“未捕获的类型错误:无法设置未定义的属性” - "Uncaught TypeError: Cannot set properties of undefined" on Javascript express.js TypeError:无法设置未定义的属性“会话” - expressjs TypeError: Cannot set property 'session' of undefined TypeError:无法设置未定义的属性(设置“转换”) - TypeError: Cannot set properties of undefined (setting 'transform')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM