遇到头疼的vue计算属性传参问题 经过各种资料查找,亲测有效
- index.vue
<van-circle
v-model="Ratedata[index].currentRate"
color="#2462E8"
fill="#fff"
layer-color="#E6E6E6"
:rate="Ratedata[index].rate"
:text="text(index)"
:speed="60"
:clockwise="true"
:stroke-width="40"
/>
复制代码
- computed中text方法传递index,利用了闭包传值
computed: {
text() {
return function (index) {
return this.Ratedata[index].currentRate.toFixed(0) + '%';
}
}
}
复制代码