From bef74ab449e154370f267fe668bec800f93c644a Mon Sep 17 00:00:00 2001 From: zouyixiong Date: Thu, 8 Feb 2018 12:06:50 +0800 Subject: [PATCH] bug fixed: add options componentInstance wx.createCanvasContext( canvasID, componentInstance ), componentInstance is required when using is wx component --- src/app.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app.js b/src/app.js index fe3ee55..e077aee 100644 --- a/src/app.js +++ b/src/app.js @@ -20,7 +20,11 @@ let Charts = function(opts) { this.opts = opts; this.config = config; - this.context = wx.createCanvasContext(opts.canvasId); + + // https://mp.weixin.qq.com/debug/wxadoc/dev/api/canvas/create-canvas-context.html + // componentInstance 自定义组件实例 this ,表示在这个自定义组件下查找拥有 canvas-id 的 + // 如果省略,则不在任何自定义组件内查找 + this.context = wx.createCanvasContext(opts.canvasId, opts.componentInstance); // store calcuated chart data // such as chart point coordinate this.chartData = {}; @@ -121,4 +125,4 @@ Charts.prototype.scrollEnd = function (e) { } } -export default Charts; \ No newline at end of file +export default Charts;