From f625af4103906f60984e6953f8cb5931efb255a1 Mon Sep 17 00:00:00 2001 From: duanlian <505441575@qq.com> Date: Wed, 30 May 2018 21:26:37 +0800 Subject: [PATCH] fix(mpvue-cropper): lifecycle error --- packages/mpvue-cropper/mpvue-cropper.vue | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/mpvue-cropper/mpvue-cropper.vue b/packages/mpvue-cropper/mpvue-cropper.vue index dd42ad5..946ba8b 100644 --- a/packages/mpvue-cropper/mpvue-cropper.vue +++ b/packages/mpvue-cropper/mpvue-cropper.vue @@ -62,12 +62,11 @@ src ? resolve(src) : reject() }) }) - } - }, - mounted () { - _wecropper = new WeCropper(Object.assign(this.option, { - id: this._canvasId - })) + }, + init () { + _wecropper = new WeCropper(Object.assign(this.option, { + id: this._canvasId + })) .on('ready', (...args) => { this.$emit('ready', ...args) }) @@ -81,6 +80,13 @@ this.$emit('beforeDraw', ...args) }) .updateCanvas() + } + }, + onLoad () { + 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