我正在用Foundation范围滑块构建一个计算器。它在Safari 9,Mac和Windows Edge 14的最新Chrome和Firefox中工作正常。但在Safari 8或IE 11中无法正常工作。在Safari 8中,我看到一个错误SyntaxError:无效的字符:'`' JavaScript代码如下所示:旧版浏览器将无法识别`in javascript
Foundation.Move(moveTime, $hndl, function() {
//adjusting the left/top property of the handle, based on the percentage calculated above
$hndl.css(lOrT, `${movement}%`);
if (!_this.options.doubleSided) {
//if single-handled, a simple method to expand the fill bar
_this.$fill.css(hOrW, `${pctOfBar * 100}%`);
} else {
//otherwise, use the css object we created above
_this.$fill.css(css);
}
});
如果我改变'为”,它不以任何浏览器。任何人有任何想法?谢谢!
当然,他们不会,ES2015不适用于旧浏览器,在新浏览器中几乎不可靠,模板字符串是ES2015的一项功能。 – adeneo
使用Babel来传输你的JavaScript https://babeljs.io/ – OregonTrail