【发布时间】:2019-12-23 10:11:22
【问题描述】:
我试图在回调中保留this 变量:
var that = this
// type1
bootbox.confirm("This is the default confirm!", function(result){
console.log(that.whatever);
});
// type2
bootbox.confirm({
message: "This is a confirm with custom button text and color! Do you like it?",
callback: function (result) {
console.log(that.whatever);
}
});
看起来很丑,有没有更好的方法?
【问题讨论】: