Qr (二维码)
纯UTS开发二维码组件,canvas绘制,非webview,无需引用原生依赖 无需安装自定义基座
支持平台
安卓 | ios | 鸿蒙 | web | 微信小程序 |
---|---|---|---|---|
√ | √ | √ | √ | √ |
示例代码
html
<template>
<t-page main-class="p-30">
<t-card main-class="tdr tdb m-30" title="Qrcode 二维码"
sub-title="纯UTS编写二维码组件,canvas绘制,非webview,无需引用原生依赖 无需安装自定义基座"></t-card>
<t-section main-class="tdr tdb mb-30" title="基础功能+主题展示"></t-section>
<t-row main-class="tdr tdb mb-30 plrt-30 fc">
<t-col main-class="fc dx">
<t-qr main-class="w-300 h-300 mbr-20" type='p' :text="qrstr"></t-qr>
</t-col>
<t-col main-class="fc dx">
<t-qr main-class="twh-300-mbr-20" type='s'>欢迎使用Tui</t-qr>
</t-col>
</t-row>
<t-button type="p" @click="test">修改二维码</t-button>
<t-section main-class="tdr tdb mb-30" title="圆点模式"></t-section>
<t-row main-class="tdr tdb mb-30-plrt-30-fc">
<t-col main-class="fc dx">
<t-qr main-class="w-300 h-300 mbr-20" type='p' mode="2" text="欢迎使用Tui"></t-qr>
</t-col>
<t-col main-class="fc dx">
<t-qr main-class="twh-300 mbr-20" mode="2" text="欢迎使用Tui"></t-qr>
</t-col>
</t-row>
<t-section main-class="tdr tdb mb-30" title="云函数生成二维码(后端)"></t-section>
<t-image main-class="twh-300 mlr-30"
src='https://tool-yundie-xyz/api/getqr?text=%E6%AC%A2%E8%BF%8E%E4%BD%BF%E7%94%A8Tui'></t-image>
</t-page>
</template>
<script setup>
import { TuiGuid } from '@/uni_modules/tui-plugins';
const qrstr = ref('欢迎使用Tui')
function test() {
qrstr.value = TuiGuid(20)
}
</script>
属性
名称 | 类型 | 默认值 | 说明 | 可选值 |
---|---|---|---|---|
size | String | mini | 组件尺寸 | large(大尺寸), medium(中尺寸), small(小尺寸), mini(迷你) |
type | String | "" | 组件类型 | info(信息), primary(正常), error(错误), warning(警告), success(成功) |
disabled | Boolean | false | 组件是否禁用 | false, true |
stop | Boolean | false | 是否阻止事件冒泡(Tui统一写法处理事件冒泡) | false, true |
hover | Boolean | true | 是否有点击效果 | false, true |
path | String | "" | 点击组件后跳转的页面路径,如果为空则响应点击事件,如果不为空则跳转页面不会响应单击事件。 | - |
mainClass | String | "" | 组件根节点的样式 | - |
nativeClass | String | "" | 组件根节点原生样式 | - |
effect | String | "normal" | 组件显示主题 | normal(正常), dark(深色), light(浅色), plain(镂空) |
mode | String | 1 | 二维码显示的模式 | 1 : 方块模式二维码2 : 圆点模式二维码 |
text | String | `` | 二维码内容 |