首页 > 解决方案 > 在 Vue 3 中,VUEX 4 突变无法访问 this._vm。如何解决?

问题描述

有任何想法吗?此突变在以前的版本中有效:

{...}

conection(state, ok = true) {
            var on = 'You are online',
                off = 'You are offline',
                status = state.sis.conected
            if (ok.code == 'auth/network-request-failed') ok = false
            if (status && !ok) this._vm.$alert.error(off)
            if (!status && ok) this._vm.$alert.log(on)
            state.sis.conected = ok ? true : false
        }, 

{...}

但是现在我收到了这个错误:未捕获的类型错误:无法读取未定义的属性“$alert”

标签: vue.jsvuex

解决方案


推荐阅读