var checkboxShow = function checkboxShow(first, second) { var $feedType = $webForm.find('[data-rule=fade-type]'); var $checkbox = $feedType.find('input[type = checkbox]'); var i; for (i = 0; i < arguments.length; i++) { arguments[i] === 0 ? $checkbox.eq(i).prop('disabled', true) : $checkbox.eq(i).prop('checked', true); } };这个函数是要根据参数判断两个复选框是选择还是禁用这么写三目运算符有什么问题啊?ESlint报错no-unused-expressions,明明生效了,但是报错了,应该怎么写?
1 回答

尚方宝剑之说
TA贡献1788条经验 获得超4个赞
要么用if-else,要么用void运算符:
void(arguments[i] === 0 ? $checkbox.eq(i).prop('disabled', true) : $checkbox.eq(i).prop('checked', true));
添加回答
举报
0/150
提交
取消