buddhism/pages/basePage/test.vue

61 lines
1.1 KiB
Vue
Raw Normal View History

2025-08-15 17:35:58 +08:00
<template>
<view class="page">
2025-08-15 17:45:56 +08:00
<view class="qrcode-container">
2025-08-15 17:35:58 +08:00
<uv-qrcode
ref="qrcode"
:value="value"
2025-08-15 17:45:56 +08:00
:options="options"
2025-08-15 17:35:58 +08:00
canvas-id="qrcode"
size="300rpx"
></uv-qrcode>
</view>
</view>
</template>
<script>
import UvQrcode from "../../uni_modules/uv-qrcode/components/uv-qrcode/uv-qrcode.vue";
export default {
components: { UvQrcode },
data() {
return {
2025-08-15 17:45:56 +08:00
value: "测试二维码内容",
2025-08-15 17:35:58 +08:00
options: {
errorCorrectLevel: "Q",
margin: 10,
2025-08-15 17:45:56 +08:00
areaColor: "#fff"
}
2025-08-15 17:35:58 +08:00
};
},
onLoad() {
this.$nextTick(() => {
this.$refs.qrcode.remake({
success: () => {
2025-08-15 17:45:56 +08:00
console.log("二维码生成成功");
2025-08-15 17:35:58 +08:00
},
fail: (err) => {
2025-08-15 17:45:56 +08:00
console.error("二维码生成失败:", err);
}
2025-08-15 17:35:58 +08:00
});
});
2025-08-15 17:45:56 +08:00
}
2025-08-15 17:35:58 +08:00
};
</script>
<style lang="scss" scoped>
.page {
background: #f5f0e7;
2025-08-15 17:45:56 +08:00
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
2025-08-15 17:35:58 +08:00
}
2025-08-15 17:45:56 +08:00
.qrcode-container {
padding: 40rpx;
background: white;
border-radius: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
2025-08-15 17:35:58 +08:00
}
</style>