javascript - 在 vuex 模块操作中访问 vue 根实例
问题描述
根据 github,访问 vue root 实例在操作中非常容易。
https://github.com/vuejs/vuex/issues/1399
我已经对其进行了测试,它可以正常工作。这是我的商店设置:
export default new Vuex.Store({
actions: {
testPieter (context) {
console.log('this in testpieter', this)
console.log('vm in testpieter', this._vm)
}
},
modules: {
userStore,
notifications,
safetyDrone
},
strict: debug
})
问题是,在模块中的操作中,当我从操作中 console.log 存储时,我似乎无法访问 vue 实例:
当我从操作中获得 console.log(this) 时,我只得到模块文件中定义的导出..
是否有一种内置/优雅的方式来访问 vue 根实例?
解决方案
推荐阅读
- c++ - C++ 需要所有声明的类型说明符和预期的非限定 ID(需要调试帮助)
- node.js - Mongo 聚合查询优化
- python - 使用 .loc() 时的 Pandas KeyError
- java - 特定时间触发时间需要多线程?
- polygon - 矢量 shp 指向具有多边形窗口的 ppp spatstat
- python - 如何在 Python 中使用 Selenium 从 github 页面 url 中抓取贡献者姓名
- mongodb - Sync two Mongodb Databases and have the client connect to the closest one
- react-admin - React Admin - 从服务器获取附加参数并传递给列表视图道具
- pyramid - 金字塔路由到类方法
- ansible - ansible如何获得最后2位数字