-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
大佬,关于在自定义组件中实现绘图 #436
Comments
@liangshiwu 感谢提供的信息。
var Charts = function Charts(opts) {
...
// this.context = wx.createCanvasContext(opts.canvasId); 为解决组件内不显示问题,替换为以下代码
this.context = opts.that ? wx.createCanvasContext(opts.canvasId, opts.that) : wx.createCanvasContext(opts.canvasId);
...
}
new wxCharts({
...
that: this // 传递组件的this上下文
});
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
在自定义组件中canvas组件注册无效,这个因为createCanvasContext方法是有两个参数,在page页面默认传了一个this,在组件里面需要手动传this。
所以修改一下才可以在自定义组件中使用,
this.context = wx.createCanvasContext(opts.canvasId, opts.that);
The text was updated successfully, but these errors were encountered: