Dialog (对话框)
支持底部和中间两种显示方向。底部对话框带有底部菜单按钮,中间对话框可关闭。两者都包含文本、图标、按钮等元素,用于展示提示信息和用户交互。
支持平台
安卓 | ios | 鸿蒙 | web | 微信小程序 |
---|---|---|---|---|
√ | √ | √ | √ | √ |
示例代码
html
<template>
<t-page main-class="p-30">
<t-dialog title="提示" direction="bottom" ref="centerDialog">
<template #button>
<t-button type="p" main-class="mb-30">底部菜单</t-button>
</template>
<t-view main-class="tdb m-30 p-30 r-50 fc">
<t-text main-class="">显示技巧提醒</t-text>
<t-icon type="p" name="apple-fill" main-class="s-100 mt-30"></t-icon>
<t-text main-class="sfwb s-40 mt-10">你学会了吗?</t-text>
<t-text main-class="p-20 sls-2 slh-45 w-80% sta-c" type="i">风格与drawer样式不同的时两边和底部有间隙?风格是否喜欢呢?</t-text>
<t-button type="p" main-class="r-100 mt-50 w-80%" @click="show">我知道了哇</t-button>
</t-view>
</t-dialog>
<t-dialog title="提示" direction="center" ref="centerDialog1" :popup-attrs="{'closeable':true}">
<template #button>
<t-button type="p">中间提示</t-button>
</template>
<t-view main-class="tdb r-20 fc w-650 p-30">
<t-text main-class="">显示技巧提醒</t-text>
<t-icon type="p" name="apple-fill" main-class="s-100 mt-30"></t-icon>
<t-text main-class="sfwb s-40 mt-10">你学会了吗?</t-text>
<t-text main-class="p-20 sls-2 slh-45 w-80% sta-c" type="i">风格与drawer样式不同的时两边和底部有间隙?风格是否喜欢呢?</t-text>
<t-button type="p" main-class="r-100 mt-50 w-80%" @click="show1">我知道了哇</t-button>
</t-view>
</t-dialog>
</t-page>
</template>
<script setup>
const centerDialog = ref<ComponentPublicInstance | null>(null)
const centerDialog1 = ref<ComponentPublicInstance | null>(null)
function show() {
centerDialog.value?.$callMethod('show')
}
function show1() {
centerDialog1.value?.$callMethod('show')
}
</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(镂空) |
popupAttrs | UTSJSONObject | {} | 弹出层的属性配置,支持t-popup的所有属性 | |
direction | String | center | 弹出方向 | center : 中间弹出left : 左侧弹出right : 右侧弹出top : 顶部弹出bottom : 底部弹出 |
事件
名称 | 返回参数 | 说明 |
---|---|---|
click | (e : UniPointerEvent) | - |
方法
名称 | 参数 | 返回值 | 说明 |
---|---|---|---|
show | - | - | 显示和关闭对话框 |
插槽
名称 | 返回值 | 说明 |
---|---|---|
name | - | 对话框名称 |
default | - | 对话框内容 |