就是转换成可以运算的 > >=
这样的代码: switch (condition.type) { case '>': status = value > condition.val ? 'Firing' : 'Normal' break case '>=': status = value >= condition.val ? 'Firing' : 'Normal' break } 我想写的简短优雅一点 if (condition.type) { status = value Symbol(condition.type) condition.val ? 'Firing' : 'Normal' }
上面这个 Symbol(condition.type) 是我臆想出来的方法😅 ,不知道是否有这样的函数,我查到了 eval()但是不符合我的需求