三元表达式判断控制插值表达式里面的内容

HTML方法三元判断

第一种

<!-- 绑定支管 {{ props.item.branchValveName }}-->
<!--如果内容为空,显示无,如果传递过来的内容不为空,展示内容-->
<td class="text-xs-left">{{ props.item.branchValveName=="" ? "无" : props.item.branchValveName }}</td>
<!-- 绑定主水泵{{ props.item.mainPumpName }} -->
<td class="text-xs-left">{{ props.item.mainPumpName==""?"无":props.item.mainPumpName}}</td>

第二种

正数显示+,负值显示-

<text class="green account_left_top">{{item.num > 0 ? `+${item.num}` : `-${item.num}`}}</text>

请添加图片描述

第三种

正数显示+,负值显示-

请添加图片描述

<text class="green account_left_top" v-if="item.num>0">+{{item.num}}</text>
<text class="green account_left_top" v-else>-{{item.num}}</text>

JS方法三元判断

data() {
	return {
		//Array(uni.getStorageSync('wx_code_pic')) 为数组
		imgList:  Array(uni.getStorageSync('wx_code_pic')).length > 0 ? Array(uni.getStorageSync('wx_code_pic')) :[],
		}
	}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值