【发布时间】:2018-09-26 11:59:29
【问题描述】:
我有下面的烤面包机代码
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(){
}
当尝试在烤面包机内部调用 onShown 方法时会抛出错误
“HTMLElement”类型上不存在隐藏面板。
这是怎么工作的?
谢谢
【问题讨论】:
-
我认为发生的情况是您使用了一些第三方组件。如果您使用第三方组件会发生什么,
this将在该组件内部使用。所以要解决这个问题,你可以把这个let me = this放在烤面包机上面,然后me.hidepanel() -
谢谢,你的想法成功了
-
不客气 :) 不确定第三方的事情,但我知道这个解决方案会起作用。
标签: javascript angular typescript angular6 angular-toastr