uni——how to use dynamic data in data (computed calculation attribute)

Case Description

Suppose my qrcodeattribute value is a dynamic value, fetched from the cache.

data() {
    
    
	return {
    
    
		qrcodeUrl:'111', 
		//像这种qrcodeUrl:user.txt 或者qrcodeUrl:'user.txt'再或者qrcodeUrl:this.user.txt都是无效的
	}
},

The above can not be written like this, you can write like this:

computed: {
    
    
	qrcodeUrl: function() {
    
    
		return this.user.txt + '';//this.user.txt是数字类型  转换为字符类型
	}
},

Case presentation

https://uniapp.dcloud.net.cn/tutorial/vue-basics.html#%E8%AE%A1%E7%AE%97%E5%B1%9E%E6%80%A7computed

Guess you like

Origin blog.csdn.net/xulihua_75/article/details/130563118