鍍金池/ 問答/HTML5  HTML/ 這個閉包怎么解決??

這個閉包怎么解決??

圖片描述

點擊箭頭的那個onclick(),,想調(diào)用oil.prototype.createChart=function(oilRealtable,objId,meteId){},
請賜教

回答
編輯回答
傲嬌范

我的思路一般是動態(tài)添加的節(jié)點,點擊事件用事件委托來做。

$(父元素).on('click','.glyphicon-eye-open',function(){
    _this.createChart(...);
})
2018年7月24日 08:56
編輯回答
萌二代
<button onclick="createChart(1)">createChart</button>

oilObj.prototype.createChart = createChart = function (a) {
    console.log(a);
}
2018年4月13日 02:26