【发布时间】:2016-12-19 21:35:46
【问题描述】:
我正在构建一个带有基础范围滑块的计算器。它在 Safari 9、适用于 Mac 和 Windows 的最新 Chrome 和 Firefox、Edge 14 中运行良好。但在 Safari 8 或 IE 11 中无法运行。在 Safari 8 中,我看到一个错误 SyntaxError: Invalid character: ' `' 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 的一项功能。
-
使用 Babel 转译你的 JavaScript babeljs.io
标签: javascript jquery safari cross-browser zurb-foundation