From 31ffe4356698a56550249c8804a8d0b16bde8b00 Mon Sep 17 00:00:00 2001 From: lijibing <635497669@qq.com> Date: Thu, 23 Mar 2023 20:01:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=20uni-app?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/mpvue-cropper/mpvue-cropper.vue | 7 ++++--- src/prepare.js | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) 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') {