👉使用方法,跟数1,2,3一样简单


基本示例

<tm-button @click="show =true" block>显示对话框 </tm-button>
<tm-dialog v-model="show" content="我是弹层内容"></tm-dialog>
1
2
<script>
	export default {
		data() {
			return {
				show:false,
			}
		},
		methods: {
			
		}
	}
</script>

1
2
3
4
5
6
7
8
9
10
11
12
13

分割按钮圆角 在上方的基础上theme="split"加上这个就可以了。

<tm-button @click="show =true" block>显示对话框 </tm-button>
<tm-dialog v-model="show" content="我是弹层内容"  theme="split"></tm-dialog>
1
2

更多见下方完整未示例和属性。

👉完整的示例


可以复制到页面直接运行

<template>
	<view class="">
		<tm-menubars title="对话框" color="bg-gradient-blue-accent" :showback="true"></tm-menubars>
		<tm-sheet>
			<view class="pa-12 text-size-s text-weight-b blue text mb-32 ">默认样式</view>
			<tm-button @click="show =true" block>显示对话框 </tm-button>
			<tm-dialog v-model="show" content="我是弹层内容"></tm-dialog>
		</tm-sheet>
		<tm-sheet>
			<view class="pa-12 text-size-s text-weight-b blue text mb-32 ">分割按钮,更换主题</view>
			<tm-button theme="bg-gradient-pink-accent" @click="show1=true" block>渐变主题对话框</tm-button>
			<tm-dialog confirmText="付钱" confirmColor="bg-gradient-pink-accent" cancelColor="pink" v-model="show1" content="我是弹层内容" theme="split"></tm-dialog>
		</tm-sheet>
		<tm-sheet>
			<view class="pa-12 text-size-s text-weight-b blue text mb-32 ">对话输入框</view>
			<tm-button @click="show3=true" block>不显示取消按钮</tm-button>
			<tm-dialog :input-val.sync="inpuval" confirmText="不能为空" :showCancel="false" model="confirm" v-model="show3" content="我是弹层内容" theme="split"></tm-dialog>
		</tm-sheet>
	</view>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<script>
	export default {
		data() {
			return {
				show:false,
				show1:false,
				show3:false,
				inpuval:''
			}
		},
		methods: {
			
		}
	}
</script>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

👉props属性表

属性名称类型可选值默认值说明
value.syncBooleantrue/falsefalse显示对话框,推荐使用v-model
blackBooleantrue/falsefalse暗黑模式
bottom-borderBooleantrue/falsetrue是否显示标题底部边线
confirmColorString任意主题名称primary确认按钮的主题颜色
cancelColorString任意主题名称primary取消按钮的主题色
confirmTextString任意文字确认确认按钮的文字
cancelTextString任意文字取消取消按钮显示的文字
contentString任意文字取消内容文字
titleString任意文字提示标题
showCancelBooleantrue/falsefalse是否显示取消按钮
over-closeBooleantrue/falsetrue点击遮罩是否关闭窗体
themeStringmerge/splitmergemerge合并按钮,split分割按钮
modelStringdialog/confirmdialog对话框类型.dialog
roundNumber任意数字4圆角
input-valString-''显示的输入框内容。 model=confirm才会起作用
disabledBooleantrue/falsefalse禁用后,点击哪都关闭不了,只能通过手动设置v-model来关闭窗体。

👉slot插槽

名称数据名称数据类型说明
#default--默认插槽,对话框正文内容
#title--对话框标题的插槽
#button--按钮插槽

👉事件

事件名称返回参数返参类型说明
@confirm--认按钮时触发,注意:如果类型为confirm则返回 的参数包含输入框的内容
@cancel--点击取消按钮时触发

👉更新日志

2021年8月20日14:8:5 初始版本。

tmzdy 于 2022/12/7 编辑 报错? | 评论?