如何将```this`''绑在函数参数中
我有搜索并尝试了一些方法,例如直接使用app.shadow.dialogue({...}。bind(this))
,但得到此错误
untuff typeError:{(中间值)(中间值)}。bind不是函数
,而是尝试执行此操作,
let dialogue = {
"title": {
"text": "Kembali ke tes?",
"description": "Anda memiliki tes yang masih berlangsung"
},
"actions": [
{
"text": "Ya",
"class": "bg-safe",
"icon": "refresh",
"action": "direct/tes"
},{
"text": "Tidak, Lihat Hasil Sebelumnya",
"class": "bg-danger",
"icon": "close",
"action": function() {
app.shadow.stop();
this.view();
}
}
]
};
dialogue.actions[1].action.bind(this);
app.shadow.dialogue(dialogue);
而是this.view
仍然没有进入范围
uck typeerror:this.view不是函数
有没有一种方法可以使语句在对象参数中可用?
I have search and try few method, like directly using app.shadow.dialogue({...}.bind(this))
but getting this error
Uncaught TypeError: {(intermediate value)(intermediate value)}.bind is not a function
And trying to do this instead
let dialogue = {
"title": {
"text": "Kembali ke tes?",
"description": "Anda memiliki tes yang masih berlangsung"
},
"actions": [
{
"text": "Ya",
"class": "bg-safe",
"icon": "refresh",
"action": "direct/tes"
},{
"text": "Tidak, Lihat Hasil Sebelumnya",
"class": "bg-danger",
"icon": "close",
"action": function() {
app.shadow.stop();
this.view();
}
}
]
};
dialogue.actions[1].action.bind(this);
app.shadow.dialogue(dialogue);
but this.view
still not get into scope
Uncaught TypeError: this.view is not a function
Is there a way to make this
statement useable inside an object argument?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您可以尝试:
希望这对您有用。
may be you can try :
hope this is useful for you.