diff --git a/packages/mpvue-cropper/mpvue-cropper.vue b/packages/mpvue-cropper/mpvue-cropper.vue index a0ca63a..5056719 100644 --- a/packages/mpvue-cropper/mpvue-cropper.vue +++ b/packages/mpvue-cropper/mpvue-cropper.vue @@ -82,7 +82,8 @@ this._wecropper = new WeCropper(Object.assign(this.option, { id: this._canvasId, targetId: this._targetId, - pixelRatio: this._pixelRatio + pixelRatio: this._pixelRatio, + componentInstance: this, })) .on('ready', (...args) => { this.$emit('ready', ...args) @@ -98,11 +99,11 @@ }) } }, - onLoad () { + mounted () { if (!this.option) { return console.warn('[mpvue-cropper] 请传入option参数\n参数配置见文档:https://we-plugin.github.io/we-cropper/#/api') } this.init() } } - \ No newline at end of file + diff --git a/src/prepare.js b/src/prepare.js index a4cf201..e33a4d5 100644 --- a/src/prepare.js +++ b/src/prepare.js @@ -34,12 +34,13 @@ export default function prepare () { self.createCtx = () => { const { id, - targetId + targetId, + createCanvasContext } = self if (id) { - self.ctx = self.ctx || wx.createCanvasContext(id) - self.targetCtx = self.targetCtx || wx.createCanvasContext(targetId) + self.ctx = self.ctx || wx.createCanvasContext(id, createCanvasContext) + self.targetCtx = self.targetCtx || wx.createCanvasContext(targetId, createCanvasContext) // 2d 没有这个方法 if (typeof self.ctx.setStrokeStyle !== 'function') {