Page({ data: { historyList: [] }, onShow() { const list = wx.getStorageSync('CALC_HISTORY') || []; this.setData({ historyList: list }); }, clearHistory() { wx.showModal({ title: '提示', content: '确定要清空所有记录吗?', success: (res) => { if (res.confirm) { wx.removeStorageSync('CALC_HISTORY'); this.setData({ historyList: [] }); } } }); } });