var app = getApp() var that; Page({ data: { date: app.globalData.month, }, onLoad() { that = this; app.globalData.showToast('success', '你好啊') }, onInitChart(F2, config) { console.log(config); const chart = new F2.Chart(config); const data = [{ date: '1月', value: 116 }, { date: '2月', value: 129 }, { date: '3月', value: 135 }, { date: '4月', value: 86 }, { date: '5月', value: 73 }, { date: '6月', value: 85 }]; chart.source(data, { date: { range: [ 0, 1 ] } }); chart.line().position('date*value'); chart.point().position('date*value').style({ stroke: '#fff', lineWidth: 1 }); chart.render(); // 注意:需要把chart return 出来 return chart; }, //时间选择 openDate() { dd.datePicker({ format: 'yyyy-MM', currentDate: that.data.date, success: (res) => { that.setData({ date: res.date }) }, }); } });