Skip to content

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>

属性

名称类型默认值说明可选值
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(镂空)
popupAttrsUTSJSONObject{}弹出层的属性配置,支持t-popup的所有属性
directionStringcenter弹出方向center: 中间弹出
left: 左侧弹出
right: 右侧弹出
top: 顶部弹出
bottom: 底部弹出

事件

名称返回参数说明
click(e : UniPointerEvent)-

方法

名称参数返回值说明
show--显示和关闭对话框

插槽

名称返回值说明
name-对话框名称
default-对话框内容