首页 文章

绑定img src

提问于
浏览
0

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

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

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

但是, img 标记不会被渲染(见下文) .

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

有任何想法吗?

enter image description here

enter image description here

1 回答

  • 2

    当附加到绑定时,记住正确可能导致这样的问题. this isn 't needed and if I' m

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

    尝试:

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

相关问题