我有一个接受可选参数的javascript函数。这在中可以正常工作Firefox
,但Google Chrome
其中显示:
Uncaught SyntaxError: Unexpected token =
我的代码,
function errorNotification(text = "Something went wrong!") {
$.pnotify({
title: 'Error',
text: text,
type: 'error'
});
}
我已经看到很多类似的问题,但是我无法意识到我的问题。
您正在使用默认参数功能,现在仅Firefox支持此功能。
function errorNotification(text) {
text = text || "Something went wrong!";
$.pnotify({
title: 'Error',
text: text,
type: 'error'
});
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句