Mask (遮罩层)
遮罩组件,轻巧覆盖于页面之上,有效锁定用户焦点,确保重要内容得以凸显和专注。
支持平台
安卓 | ios | 鸿蒙 | web | 微信小程序 |
---|---|---|---|---|
√ | √ | √ | √ | √ |
示例代码
html
<template>
<t-page>
<t-mask ref='mask' :transition="transition" :duration="500" />
<t-card main-class="mltr-30" title="Mask 遮罩层" sub-title=" 遮罩组件,轻巧覆盖于页面之上,有效锁定用户焦点,确保重要内容得以凸显和专注。"></t-card>
<t-group title="基础演示">
<t-button @click="onClick(true)" type="p" @change='change'>{{show?'关闭':'打开'}}</t-button>
</t-group>
<t-group title="不使用过渡动画">
<t-button @click="onClick(false)" type="p">{{show?'关闭':'打开'}}</t-button>
</t-group>
<t-group>
<t-button @click="nvto" type="p">返回主页</t-button>
</t-group>
</t-page>
</template>
<script setup>
const show = ref(false)
const mask = ref<ComponentPublicInstance | null>(null)
const transition = ref(true)
function onClick(type : boolean) {
transition.value = type
mask.value?.$callMethod('show')
}
function change(e : boolean) {
show.value = e
}
function nvto() {
uni.navigateBack()
}
</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(镂空) |
duration | Number | 500 | 动画的时间 单位ms | |
transition | Boolean | true | 是否显示动画 |
事件
名称 | 返回参数 | 说明 |
---|---|---|
change | - | 状态发生变化时触发 |
方法
名称 | 参数 | 返回值 | 说明 |
---|---|---|---|
show | - | - | 打开遮罩层 |
transitionend | - | - | |
maskClick | - | - |
插槽
名称 | 返回值 | 说明 |
---|---|---|
default | - |