Binding img src

て烟熏妆下的殇ゞ 提交于 2020-01-06 21:12:10

问题


I have an img tag in a Vue component with a binded src attribute to Vuex state.

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

I am successfully updating that state object in Vuex (see below).

However the img tag does not get rendered (see below).

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.

Any ideas?


回答1:


When attaching to bindings, this isn't needed and if I'm remembering right can cause issues like this.

Also your store structure looks like you have a module imageStore this would namepace of the imageDataURI element.

Try:

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


来源:https://stackoverflow.com/questions/41859827/binding-img-src

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!