diff --git a/src/packages/__VUE/avatarcropper/index.taro.vue b/src/packages/__VUE/avatarcropper/index.taro.vue index 16ec66299d..13cb83ccc9 100644 --- a/src/packages/__VUE/avatarcropper/index.taro.vue +++ b/src/packages/__VUE/avatarcropper/index.taro.vue @@ -245,6 +245,9 @@ export default create({ // base64转图片(canvasImage) const dataURLToCanvasImage = (canvas: any, dataURL: string): Promise => { + if (!canvas) { + return Promise.reject(new Error('Invalid canvas element')) + } return new Promise((resolve) => { const img = canvas.createImage() img.onload = () => resolve(img)