| | |
| | | }; |
| | | }, |
| | | methods: { |
| | | _initDraw() { |
| | | this.canvasContext = Taro.createCanvasContext(this.cavId, this); |
| | | const $container = $(this.$refs.drawing).parent(); |
| | | setTimeout(() => { |
| | | $container.width().then(w => (this.cavWidth = w)); |
| | | $container.height().then(h => (this.cavHeight = h)); |
| | | }, 0); |
| | | }, |
| | | $onDraw(callback) { |
| | | this._initDraw(); |
| | | this.layerOpened = true; |
| | | this._callback = callback; |
| | | this.handleRestDraw(); |
| | |
| | | }, |
| | | mounted() { |
| | | this.$nextTick(() => { |
| | | this.canvasContext = Taro.createCanvasContext(this.cavId, this); |
| | | const $container = $(this.$refs.drawing).parent(); |
| | | setTimeout(() => { |
| | | $container.width().then(w => (this.cavWidth = w)); |
| | | $container.height().then(h => (this.cavHeight = h)); |
| | | }, 0); |
| | | this._initDraw(); |
| | | }); |
| | | }, |
| | | }; |