From 0396d398bea811f5650d04ce5b55a232b4f58b98 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Thu, 27 Mar 2025 17:07:52 +0800 Subject: [PATCH] 移除 link-rules --- plugins/qrcode/CQRCode.vue | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/plugins/qrcode/CQRCode.vue b/plugins/qrcode/CQRCode.vue index de005a7..5658468 100644 --- a/plugins/qrcode/CQRCode.vue +++ b/plugins/qrcode/CQRCode.vue @@ -6,22 +6,27 @@ <template> <view class="c-qr-code"> <canvas ref="canvas"></canvas> - <button + <AtButton v-if="downloadable" - @tap="evt => handleSaveToAlbum()" - >保存到手机</button> + type="primary" + full + :onClick="evt => handleSaveToAlbum()" + >保存到手机</AtButton> </view> </template> <script> import Taro from '@tarojs/taro'; import { $ } from '@tarojs/extend'; +import { AtButton } from 'taro-ui-vue'; import QRCode from 'qrcode'; import './cQrCode.scss'; export default { name: 'CQRCode', - components: {}, + components: { + AtButton, + }, props: { content: { type: String, @@ -65,7 +70,7 @@ canvasDom, this.content, { - width: this.size, + width: this.size * 2, margin: this.margin, }, err => { @@ -73,14 +78,14 @@ console.error(err); return; } - } + }, ); }, }, mounted() { if (process.env.TARO_ENV === 'h5') { const canvasBox = $(this.$refs.canvas.$el); - const finderTimer = setInterval(() => { + this.finderTimer = setInterval(() => { const canvasDom = canvasBox.find('canvas'); if (canvasDom.length === 0) { return; @@ -90,10 +95,13 @@ } this._renderQRCodeH5(canvasDom[0]); this.lastContent = this.content; - }, 10); + }, 100); } else { // TODO: 小程序中获取canvas } }, + beforeDestroy() { + clearInterval(this.finderTimer); + }, }; </script> \ No newline at end of file -- Gitblit v1.9.1