为了账号安全,请及时绑定邮箱和手机立即绑定

如何在vue模版的属性里使用 vuex 的 store 的值?

如何在vue模版的属性里使用 vuex 的 store 的值?

慕少森 2018-08-29 17:33:13
这是vuex官网给出的示例,很容易理解const Counter = {   template: `<div>{{ count }}</div>`,  computed: {     count () {           return store.state.count     }        } }我现在想在html的属性里使用count,如const Counter = {   template: `<img src="{{img}}">`,  computed: {     count () {           return store.state.img     }   } }但是这么写是不行的,请问如过要实现这种效果该怎么实现呢?
查看完整描述

2 回答

?
万千封印

TA贡献1891条经验 获得超3个赞

只要用到vue实例中的数据,在html中的属性前都要使用:绑定

查看完整回答
反对 回复 2018-09-09
?
翻过高山走不出你

TA贡献1875条经验 获得超3个赞

用 :src="$store.state.img" 或者 :src="count"

查看完整回答
反对 回复 2018-09-09
  • 2 回答
  • 0 关注
  • 5283 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信