三目运算的运用,条件1:条件2 ?结果1(true) : 结果2(false)
三目运算的运用,条件1:条件2 ?嵌套三目运算 :嵌套三目运算
<div>
<el-button
type="success"
size="mini"
:disabled="isShowTitle"
@click="handleGetALL"
>
{{ getAllTitle }}
</el-button>
<el-button
type="primary"
size="mini"
:disabled="isShowDetail"
@click="handleCheckHistoryALL(checkedId)"
>
审核记录
</el-button>
</div>
// 提交按钮禁用条件
isShowTitle() {
if (this.checkedList.length > 0) {
return false
}
if (this.rowList > 0) {
return false
}
return true
},
// 审核按钮禁用条件
isShowDetail() {
if (this.checkedList.length === 1) {
return false
}
if (this.rowList === 1) {
return false
}
return true
}
// 提交按钮名字
getAllTitle() {
const title = '提交'
let result = this.checkedList.length === 0 ? title
: this.checkedList.length !== this.cityOptions.length ? `部分${title}` : `全部${title}`
if (this.checkedList.length === 0 && this.rowList > 0) {
result = `列表${title}`
}
return result
},