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.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
2 回答4.7k 阅读✓ 已解决
4 回答4.3k 阅读✓ 已解决
你可以想成在
template
裡面的操作,就是在組件scope
下。