JavaScript Safari - 语法错误:意外标记“>" [英] JavaScript Safari - SyntaxError: Unexpected token '>'
问题描述
我遇到了这个 JavaScript 代码段在 Firefox/Chrome 中运行时没有任何问题的问题,而 Safari 出现错误:SyntaxError: Unexpected token '>'".
I have the problem that this JavaScript snippet runs in Firefox / Chrome without any problem, and Safari I get error: "SyntaxError: Unexpected token '>'".
代码如下:
window.onclick = (test) => {
const googleWindow = window.open();
fakeAjax(response => {
googleWindow.location.replace(`https://google.com?q=${response}`);
});
};
function fakeAjax(callback) {
setTimeout(() => {
callback('example');
}, 1);
}
我用谷歌搜索过,已经在论坛上看到过,那里的问题经常出现,很遗憾我没有找到合适的解决方案.
I've googled and have already seen here in the forum, the problem there appears often, unfortunately I have not found a suitable solution.
先谢谢你最好的问候
推荐答案
Arrow function ()=>{} 是 es6 特性,firefox 和 chrome 都已经支持.但是 safari 旧版本没有.请查看 http://kangax.github.io/compat-table/es6/了解更多信息.
Arrow function ()=>{} is es6 feature, firefox and chrome both are already supported. But safari old version doesn't. Please check http://kangax.github.io/compat-table/es6/ for more information.
这篇关于JavaScript Safari - 语法错误:意外标记“>"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!