我有以下代码:
$.Object.Test = {
init: function() {
this.verify();
},
verify: function() {
alert("checking");
}
}
这非常有效,但是当我将其更改为:
$.Object.Test = {
init: () => {
this.verify();
},
verify: () => {
alert("checking");
}
}
它不再起作用
我不明白为什么,有区别吗?我的老师曾经说过,第二种方式只是写function(){}
我也尝试过:
$.Object.TestTwo = {
init: (x) => {
var message = "Code..."
x.action(message);
}
}
$.Object.TestTwo.init(
x = {
type: 'Success',
url: 'SomeSite.com',
action: (r) => {
alert("Sending " + r)
}
});
()=>{}
和{{1}
因为我真的不明白为什么它在$.Object.Test
中不起作用
我正在尝试寻找一些解释,但没有找到