Vue计算属性的使用

不传参

computed: {
    // 仅读取
    aDouble: function () {
      return this.a * 2
    },
    // 读取和设置
    aPlus: {
      get: function () {
        return this.a + 1
      },
      set: function (v) {
        this.a = v - 1
      }
    }
  }

在插槽中传参

<img style="width: 100px" :src="_downloadUrl(scope.row)" class="image">

computed: {
    _downloadUrl(){
      return function(row){
        return 'process.env.VUE_APP_UPLOAD_URL' + row.savePath + '/' + row.saveName
      }
    }
  }
posted @ 2022-08-22 18:22  Kelvin's  阅读(21)  评论(0)    收藏  举报