this.fixed = scrollTop > 140 ? true : false
遇到 eslint 报错如下
error Unnecessary use of boolean literals in conditional expression no-unneeded-ternary
即 “该情况下条件表达式中没必要写出布尔值”
故可以简化如下
this.fixed = scrollTop > 140
this.fixed = scrollTop > 140 ? true : false
遇到 eslint 报错如下
error Unnecessary use of boolean literals in conditional expression no-unneeded-ternary
即 “该情况下条件表达式中没必要写出布尔值”
故可以简化如下
this.fixed = scrollTop > 140