safari中的默认函数参数值不起作用 [英] Default function parameter value in safari is not working
本文介绍了safari中的默认函数参数值不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用angularjs,并且仅在safari中遇到 null
分配问题。它在chrome和firefox中工作。
I am using angularjs, and having problem with null
assignment in safari only. Its working in chrome and firefox.
$scope.submit = function(id=null){
}
我收到此错误
SyntaxError: Expected token ')'
当我删除 null
,它只是有效。我不知道为什么!
when I remove null
, It just works. I don't know why !
$scope.submit = function(id){
}
请帮助我理解为什么这只发生在safari上?
Please help me to understand why this happening only with safari ?
推荐答案
默认参数< Safari中尚不支持来自ES2015的/ a>。请查看兼容性表。
目前基本支持提供Chrome 49和Firefox 15.
At the moment the basic support provide Chrome 49 and Firefox 15.
但是您可以使用以下ES5代码来实现相同的目标:
But you can use the following ES5 code to achieve the same:
$scope.submit = function(id) {
if (id === undefined) {
id = null;
}
}
这篇关于safari中的默认函数参数值不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文