问题描述
限时送ChatGPT账号..我在一个 Vue 组件中有一个 img
标签,它的 src
属性绑定到 Vuex 状态.
I have an img
tag in a Vue component with a binded src
attribute to Vuex state.
<img :src="this.$store.state.imageDataURI">
我在 Vuex 中成功更新了该状态对象(见下文).
I am successfully updating that state object in Vuex (see below).
但是 img
标签没有被渲染(见下文).
However the img
tag does not get rendered (see below).
我可以用 getter 解决这个问题,但只是好奇为什么这不起作用.我怀疑这与 Vue 的反应性模型有关.
I can fix this with getters but just curious as to why this doesn't work. I suspect this has to do with Vue's reactivity model.
有什么想法吗?
推荐答案
当附加到绑定时,this
不是必需的,如果我没记错的话可能会导致这样的问题.
When attaching to bindings, this
isn't needed and if I'm remembering right can cause issues like this.
此外,您的商店结构看起来像您有一个模块 imageStore
这将命名 imageDataURI
元素.
Also your store structure looks like you have a module imageStore
this would namepace of the imageDataURI
element.
试试:
<img :src="$store.state.imageStore.imageDataURI">
这篇关于绑定img src的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论