我有下面的 toastr 代码
toastr.success("<br /><br /><button type='button' id='confirmationRevertYes' class='btn clear'>Yes</button>",'delete item?',
{
closeButton: false,
allowHtml: true,
onShown: function (toast) {
$("#confirmationRevertYes").click(function(){
hidepanel(); // not working
this.hidepanel(); // not working
});
}
});
我在外面有一个功能
hidepanel(){
}
当尝试调用内部 toastr onShown 方法时,它会抛出错误
hidepanel does not exist on type 'HTMLElement'.
这怎么行?
谢谢
最佳答案
假设您有一个函数调用 hidepanel
,请使用 =>
表达式
toastr.success("<br /><br /><button type='button' id='confirmationRevertYes' class='btn clear'>Yes</button>",'delete item?',
{
closeButton: false,
allowHtml: true,
onShown: (toast) => {
$("#confirmationRevertYes").click(() =>{
this.hidepanel();
});
}
});
关于javascript - 调用 toastr onShown 事件中的其他函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52517249/