三目运算符要求(布尔表达式 ? 值0:值1;),问号后面要求是值,(下面是封装获取内联样式的兼容性函数写法)然而
getComputedStyle ? return getComputedStyle(ele)[style] : return ele.currentStyle[style];
return 并不是一个合法的值,也不是三目运算符要求的期望表达
可以写成
return getComputedStyle ? getComputedStyle(ele)[style] : ele.currentStyle[style];
返回这个运算语句。