vue 计算属性computed方法内传参

9,636 阅读1分钟

vue计算属性传参问题 经过各种资料查找,亲测有效

  1. 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"
 />
  1. computed中text方法传递index,利用了闭包传值
computed: {
  text() {
      return function (index) {
          return this.Ratedata[index].currentRate.toFixed(0) + '%';
      }
  }
}