如何从指令访问存储中的值?存储区中的值是从我的主要app.js文件更新的-它是页面的滚动位置。
<div v-test>hello</div>
我的主app.js文件中有商店的吸气剂:
computed: {
...mapGetters('Window', {
scroll: 'scrollPos',
}),
},
directives: {
test: {
inserted: function (el, binding, vnode) {
//get store value here
}
},
},
我已经尝试在指令中这样访问商店:
console.log(vnode.context.scroll);
但是我总是得到初始值,而不是滚动显示的更新值。
因此,我需要在我的指令中获取该商店的值的最新更新值-可以吗?