Element UI el-button @click event using ternary expression is invalid

I believe that many people enter the pit, but it's just a matter of details.
If you use ternary expressions, you need to add parentheses in the method, if you don’t use ternary expressions, you can leave the method without parentheses.

<!-- 使用三元表达式,handleAdd方法要加括号 -->
<el-button @click.native="isCreate ? '' : handleAdd()">新增</el-button>
<!-- 没有使用三元表达式,handleAdd可以不加括号 -->
<el-button @click="handleAdd">新增</el-button>

Guess you like

Origin blog.csdn.net/weixin_43908123/article/details/107964667