2 回答

TA貢獻(xiàn)1850條經(jīng)驗(yàn) 獲得超11個(gè)贊
你能試試嗎
initializeGraph() {
const that = this;
this.graph = new Chart('graph', {
type: 'pie',
data: {
datasets: [{
data: [1,2],
backgroundColor: ['#RRGGBB', '#FF0000'],
}],
labels: ['blue','red']
},
options: {
onClick : function(event,elements) {
that.hello();
}
}
});
}

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超9個(gè)贊
您是否嘗試使用箭頭功能?(e) => {}
使用箭頭函數(shù)時(shí)變量的范圍this
不同。箭頭函數(shù)從父作用域繼承“this”,在您的情況下,它可能指的是全局作用域。
添加回答
舉報(bào)