问题
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