下面是自己用到的场景
<el-link
type="primary"
:style="{
'margin-left': '10px',
'border-bottom': '1px solid',
color: scope.row.title == '' ? 'lightgrey' : 'DodgerBlue',
}"
:underline="true"
@click="handleEdit(scope.row._id)"
>{{
scope.row.title == '' ? '标题为空' : scope.row.title
}}</el-link`
<el-input
v-model="editForm.title"
:maxlength="
'maxlength' in editTemplate.title
? editTemplate.title.maxlength
: false
"
show-word-limit
clearable
></el-input>
<span v-bind:style="{'display':config.isHaveSearch ? 'block':'none'}" >搜索</span>
补充:当设置maxlength为false时,表示没有限制。
变量条件真假
[] >>true
>>false
{} >>true
0 >>false
null >>false
undefined >>false
if(a && a.b) => 当a未null/undefined时,可以避免以下错误
Cannot read property 'b' of null
Cannot read property 'b' of undefined