vue computed进行异步计算

vue yekong 1724℃

git地址

vue-async-computed

安装依赖

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
	}
}

实例

uniapp 异步计算获取图片并可点击大图预览

喜欢 (0)