const store = new Vuex.Store({
state: {
a: 'a'
}
});
<li v-for="item in list">
<img src="this.$store.state.a" />
</li>
为什么这个src没有被渲染?
very much Thanks in advance~~~
const store = new Vuex.Store({
state: {
a: 'a'
}
});
<li v-for="item in list">
<img src="this.$store.state.a" />
</li>
为什么这个src没有被渲染?
very much Thanks in advance~~~
结贴~~~
v-for循环中,貌似this指向并不是Vue,在模板中
<img :src="a" />
data () {
return {
a: this.$store.state.a
}
}
10 回答11.7k 阅读
2 回答3.2k 阅读✓ 已解决
4 回答4.6k 阅读✓ 已解决
4 回答2.1k 阅读✓ 已解决
4 回答2.2k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
3 回答5.1k 阅读
你可以想成在
template
裡面的操作,就是在組件scope
下。