uni-app三目运算 uni-app监听属性

三目运算

<text>{{mag>10 ? '优秀' : ""}}</text>
		
三目运算的高级用法
大于1000用kg表示  小于1000,用g表示  添加括号是因为提高他的优先级哈
<text>{{weight > 1000 ? (weight/1000)+"kg" : weight}}</text>		

uni-app监听属性 跟vue是一样的哈

点击【页面主操作 Normal】 就会触法watch监听的这个值哦!!!

	监听属性哈  安卓也是可以的哈  小程序   H5
		<view>
			<text>{{mag}}</text>
		</view>
		
		 <button type="primary" @tap="anniu">页面主操作 Normal</button>

		 data:{
                     mag:0
                 },
		 methods: {
		 	anniu(){
		 		this.mag=this.mag+1;
		 	}
		 },
		 watch:{
		 	mag:function(new,old){
		 		console.log("watch",this.mag)
		 	}
		 }
原文地址:https://www.cnblogs.com/IwishIcould/p/12184453.html