我有一个 VueX 商店,设置如下:
const state = reactive({
get account() {
return accountInfo
}
})
const getters = {
getAccountInfo: () => computed(() => state.account())
在我的路由守卫中用作
router.beforeEach(to, from, next) => {
...
let account = store.getters.getAccountInfo()
console.log(account)
...
}
返回一个
ComputedRefImpl
,考虑到我需要访问accountInfo
对象中的变量以验证帐户是否存在,这是一个问题。
我曾尝试使用
toRaw()
来转换返回值,以及 lodash.cloneDeep
和其他各种访问深层结构化对象的方法(就像尝试记录 account.name 或任何返回值 undefined
)。
应该如何处理这个问题?
谢谢!