uni-app 计算属性 computed

功能:=》大于1000用kg表示 小于1000,用g表示

	计算属性  计算属性必须是有一个返回值的哦  
	在html写被计算的值
	在computed中去直接调用哈

		<view>
			<text>{{jisuweight}}</text>
		</view>
		
		data() {
			return {
				weight:1110,
			}
		},
		computed:{
			jisuweight(){
				return this.weight>1000 ? (this.weight/1000)+"kg" : this.weight;
			}
		},
posted @ 2020-01-12 19:35  南风晚来晚相识  阅读(12511)  评论(0编辑  收藏  举报