1.安装必要的组件库qrcode.js
npm install qrcode 2.在项目中引入库
import Qrcode from 'qrcode' 3.从后端获取微信支付二维码链接
从后端返回的数据中中获取二维码链接(链接一般是weixin://wxpay/xxxxxxxxxx)
Qrcode.toDataURL(你的二维码链接).then((url) => { showCode.value = true//显示弹窗 codeImg.value = url//显示二维码图片 }) 4.在vue中显示弹窗组件(支付二维码)
<van-icon name="cross" class="close" @click="closeCode" />
微信支付