@@ -4,14 +4,25 @@ import { ref } from 'vue';
4
4
let alertInfo = ref (' 这个模态框本质是一个弹出的遮罩层,在遮罩层里你可以定义任意类型的 Card, Dialog, 或者不定义😶🌫️, Vben并没有封装默认的类型,所以你可以根据自己的实际业务定制😋' )
5
5
let defaultModalShow = ref (false )
6
6
let isModalShow = ref (false )
7
+ let dialogModalShow = ref (false )
7
8
const cTitle = ref (' 这个模态框里装了一个卡片📇' )
8
9
const cContent = ref (' 🚧山重水复疑无路🚧' )
9
10
const aTitle = ref (' Card类型的Modal' )
10
11
const bTitle = ref (" 默认的Modal" )
11
12
const dTitle = ref (' Dialog类型的Modal' )
13
+ const dialogTitle = ref (' Dialog类型的Modal的标题' )
14
+ const dialogContent = ref (' 你确认?' )
15
+ const dialogPositiveText = ref (' 确认' )
16
+ const dialogNegativeText = ref (' 算了' )
17
+
18
+ // 关闭 dialogModalShow
19
+ function CloseDialog() {
20
+ dialogModalShow .value = ! dialogModalShow .value
21
+ }
12
22
13
23
</script >
14
24
25
+
15
26
<template >
16
27
<div class =" m-2 grid grid-cols-12 gap-4" >
17
28
<div class =" col-start-1 col-span-8" >
@@ -30,7 +41,7 @@ const dTitle = ref('Dialog类型的Modal')
30
41
31
42
<div class =" col-start-7 col-span-3" >
32
43
<VbenCard :title =" dTitle" >
33
- <VbenButton >点我</VbenButton >
44
+ <VbenButton @click = " dialogModalShow = true " >点我</VbenButton >
34
45
</VbenCard >
35
46
</div >
36
47
@@ -42,6 +53,11 @@ const dTitle = ref('Dialog类型的Modal')
42
53
<VbenCard class =" w-1/2" :title =" cTitle" role =" dialog" >{{ cContent }}</VbenCard >
43
54
</VbenModal >
44
55
56
+ <VbenModal v-model:show =" dialogModalShow" @PositiveClick =" CloseDialog" :title =" dialogTitle" @maskClick =" CloseDialog"
57
+ @NegativeClick =" CloseDialog" :content =" dialogContent" :positive-text =" dialogPositiveText"
58
+ :negative-text =" dialogNegativeText" preset =" dialog" >
59
+ </VbenModal >
60
+
45
61
</div >
46
62
</template >
47
63
0 commit comments