绑定img src

时间:2017-01-25 19:16:28

标签: javascript vue.js vuex

我在Vue组件中有一个img标记,其中绑定的src属性为Vuex状态。

<img :src="this.$store.state.imageDataURI">

我在Vuex中成功更新了该状态对象(见下文)。

但是img标记未呈现(参见下文)。

我可以用吸气剂解决这个问题,但只是好奇为什么这不起作用。我怀疑这与Vue的反应模型有关。

有什么想法吗?

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:2)

当附加到绑定时,不需要this,如果我记得正确可能导致这样的问题。

此外,您的商店结构看起来有一个模块imageStore,这将是imageDataURI元素的名称空间。

尝试:

<img :src="$store.state.imageStore.imageDataURI">
相关问题