Safari:SyntaxError:使用保留字'class'
问题描述:
我想让我的网站适合所有知名的浏览器 在所有浏览器中,我的JavaScript代码正在工作,但在Safari中无法使用。Safari:SyntaxError:使用保留字'class'
我得到一个错误的Safari:“语法错误:使用保留字‘类’的”
class _MontInit {
constructor() {}
sendXMLHTTPRequest(url, data, method, callback, error) {
var xmlHTTP = new XMLHttpRequest(); // new HttpRequest instance
xmlHTTP.open(method, url);
xmlHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
xmlHTTP.onload = callback;
xmlHTTP.onerror = error;
xmlHTTP.setRequestHeader('Cache-Control', 'no-cache');
xmlHTTP.send(data);
}
}
错误的位置是在类单词在MontInit之前。 Web解决方案之一是添加“严格使用”。但它没有帮助。 任何想法?
您使用的是哪个版本的Safari? – Quentin
我在5.1和8上检查过,同一问题 – AlexBerd
那些版本不支持'class',请在https://caniuse.com/#feat=es6-class – yuriy636