VUE中v-bind能不能直接调用methods里的我方法?

//这是一个table里的其中一行
<el-link :underline="false" :href="getBaseUrl(this.bucket,scope.row.key)">下载文件</el-link>
methods: {
  getBaseUrl(bucket,key){
     let _that = this
     axios.get('/admin/qiniu/geturl',{params:{'bucket': bucket, 'key': key}})
        .then(function (response) {
            return response.data
        })
        .catch(function (error) {
            console.log(error)
        })
    },
}

v-bind不能直接调用methods里的返回值吗?应该怎么写才对?

阅读 6.5k
4 个回答

为什么不用onclick呢

可以调用平常的mothods方法return一个数据,但是异步的,貌似直接写在模板里是不行的

异步的不行,需要你绑定一个变量,在异步获取数据后修改这个变量值

你data(){}里面加个字段绑定到href上异步请求完给字段赋值就好了

推荐问题