git地址
安装依赖
npm install --save vue-async-computed
引用
import AsyncComputed from 'vue-async-computed'
Vue.use(AsyncComputed)
使用
asyncComputed: {
async imgSrc() {
var imgSrc = ""
var str = new RegExp("http");
console.log(str.test(this.src))
if (str.test(this.src)) {
imgSrc = this.src
} else {
imgSrc = await this.eventHandler()
}
return imgSrc
}
}