2
2
<div class =" index" >
3
3
<h1 style =" text-align : center ;margin-bottom : 35px ;margin-top : 35px ;" >Index page</h1 >
4
4
<div style =" width : 100% ;display : grid ; grid-gap : 15px ; grid-template-columns : repeat (auto-fill , 200px );justify-content : center " >
5
- <button class =" dg-btn" @click =" testBtnHandler('alert')" >Click Alert</button >
6
- <button class =" dg-btn" @click =" testBtnHandler('confirm')" >Click Confirm</button >
7
- <button class =" dg-btn" @click =" testBtnHandler('soft')" >Click Confirm | soft</button >
8
- <button class =" dg-btn" @click =" testBtnHandler('loading')" >Click Confirm | loading</button >
9
- <button class =" dg-btn" @click =" testBtnHandler('hard')" >Click Confirm | hard</button >
10
- <button class =" dg-btn" @click =" testBtnHandler('prompt')" >Click Prompt</button >
5
+ <button class =" dg-btn" @click =" testBtnHandler('alert')" >Alert</button >
6
+ <button class =" dg-btn" @click =" testBtnHandler('confirm')" >Confirm</button >
7
+ <button class =" dg-btn" @click =" testBtnHandler('prompt')" >Prompt</button >
8
+ <button class =" dg-btn" @click =" testBtnHandler('soft')" >Confirm | soft</button >
9
+ <button class =" dg-btn" @click =" testBtnHandler('loading')" >Confirm | loading</button >
10
+ <button class =" dg-btn" @click =" testBtnHandler('hard')" >Confirm | hard</button >
11
+ <button class =" dg-btn" @click =" openDialog()" >Open from setup</button >
11
12
</div >
12
13
<hr style =" margin : 35px 0 ;" />
13
14
<div style =" width : 100% ;display : grid ; grid-gap : 15px ; grid-template-columns : repeat (auto-fill , 200px );justify-content : center " >
14
- <button class =" dg-btn" v-confirm =" 'Please confirm!'" >Click Directive</button >
15
- <a href =" https://example.com" v-confirm:soft =" 'Visit external link?'" >Example website</a >
16
- To see how many seconds have elapsed, click <a href =" javascript:" v-confirm =" `${secondsElapsed} Seconds`" >here</a >
15
+ <div >< button class =" dg-btn" v-confirm =" 'Please confirm!'" >Directive</button ></ div >
16
+ <div >< a href =" https://example.com" v-confirm:soft =" 'Visit external link?'" >Example website</a ></ div >
17
+ < div > To see how many seconds have elapsed, click <a href =" javascript:" v-confirm =" `${secondsElapsed} Seconds`" >here</a ></ div >
17
18
</div >
18
19
</div >
19
20
</template >
20
21
21
22
<script lang="ts">
22
- import {defineComponent , nextTick , ref } from " vue" ;
23
+ import {defineComponent , inject , ref } from " vue" ;
23
24
24
25
export default defineComponent ({
25
26
methods: {
@@ -28,7 +29,12 @@ export default defineComponent({
28
29
this [type ]();
29
30
},
30
31
alert() {
31
- this .$dialog .alert (' Hello world!' )
32
+ this .$dialog .alert ({
33
+ title: ' Request failed' ,
34
+ body: ' The requested resource is no longer available. It may have been moved or deleted' ,
35
+ }, {
36
+ okText: ' Dismiss'
37
+ })
32
38
},
33
39
confirm() {
34
40
this .$dialog .confirm (' If you delete this record, it\' ll be gone forever.' )
@@ -82,13 +88,15 @@ export default defineComponent({
82
88
},
83
89
},
84
90
setup() {
91
+ const dialog = inject (' $dialog' )
92
+ const openDialog = () => dialog .alert (' Hello world!' )
85
93
const secondsElapsed = ref (0 )
86
94
const tick = () => {
87
95
secondsElapsed .value += 1
88
96
setTimeout (() => tick (), 1000 )
89
97
}
90
98
tick ()
91
- return { secondsElapsed }
99
+ return { secondsElapsed , openDialog }
92
100
}
93
101
})
94
102
@@ -97,11 +105,7 @@ export default defineComponent({
97
105
<style >
98
106
@media (min-width : 1024px ) {
99
107
.index {
100
- min-height : 100vh ;
101
- display : flex ;
102
- flex-direction : column ;
103
- align-items : center ;
104
- justify-content : center ;
108
+ max-width : 700px ;
105
109
}
106
110
107
111
.dg-btn {
0 commit comments