Files
2026-09-13 17:45:52 +08:00

46 lines
925 B
Vue

<template>
<view class="referral-qr-code" aria-label="推荐注册链接二维码">
<image v-if="imageSource" :src="imageSource" mode="aspectFit" />
</view>
</template>
<script setup>
import { computed } from "vue";
import createQrCode from "qrcode-generator";
const props = defineProps({
value: {
type: String,
required: true,
},
});
const imageSource = computed(() => {
const value = props.value.trim();
if (!value) return "";
const qrCode = createQrCode(0, "M");
qrCode.addData(value, "Byte");
qrCode.make();
return qrCode.createDataURL(8, 16);
});
</script>
<style scoped lang="scss">
.referral-qr-code {
display: flex;
width: 280rpx;
height: 280rpx;
align-items: center;
justify-content: center;
padding: 14rpx;
border: 1rpx solid rgba(128, 89, 49, 0.24);
border-radius: 8rpx;
background: #fff;
}
.referral-qr-code image {
width: 100%;
height: 100%;
}
</style>