为什么在我的脚本中写着 为什么在 .运算符 当我包含这样的脚本时
this.switch = function(){
if (this.status == "enabled")
{
this.disable();
this.stop();
}
else
{
this.enable();
}
}
该脚本旨在将状态从已启用转移到已禁用
最佳答案
switch
是保留关键字(用于 ... switch
语句!)。如果你命令式,绝对必须使用这个名字,写 this['switch']
代替,但使用起来会很烦人。
打开/关闭某项功能的通用名称是 toggle()
。
关于出现 javascript : why missing name after . 运算符(operator)警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4429584/