Skip to content

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>

属性

名称类型默认值说明可选值
sizeStringmini组件尺寸large(大尺寸), medium(中尺寸), small(小尺寸), mini(迷你)
typeString""组件类型info(信息), primary(正常), error(错误), warning(警告), success(成功)
disabledBooleanfalse组件是否禁用false, true
stopBooleanfalse是否阻止事件冒泡(Tui统一写法处理事件冒泡)false, true
hoverBooleantrue是否有点击效果false, true
pathString""点击组件后跳转的页面路径,如果为空则响应点击事件,如果不为空则跳转页面不会响应单击事件。-
mainClassString""组件根节点的样式-
nativeClassString""组件根节点原生样式-
effectString"normal"组件显示主题normal(正常), dark(深色), light(浅色), plain(镂空)
modeString1二维码显示的模式1: 方块模式二维码
2: 圆点模式二维码
textString``二维码内容