This repository was archived by the owner on Jan 9, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +81
-7
lines changed Expand file tree Collapse file tree 2 files changed +81
-7
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ Next create your Dialog component that will be launched from method. Name it Inf
39
39
</GDialog >
40
40
```
41
41
42
+ ))) method-switch
43
+
44
+ ::: vue-slot composition
42
45
``` js
43
46
// InfoDialog.vue
44
47
import { computed } from ' vue'
@@ -49,13 +52,11 @@ export default {
49
52
components: {
50
53
GDialog,
51
54
},
52
-
53
55
props: {
54
56
modelValue: {
55
57
type: Boolean ,
56
58
default: false ,
57
59
},
58
-
59
60
info: {
60
61
type: String ,
61
62
required: true ,
@@ -79,9 +80,79 @@ export default {
79
80
},
80
81
}
81
82
```
83
+ :::
84
+
85
+ ::: vue-slot option
86
+ ``` js
87
+ // InfoDialog.vue
88
+ import { GDialog } from ' gitart-vue-dialog'
89
+
90
+ export default {
91
+ name: ' BaseDialog' ,
92
+ components: {
93
+ GDialog,
94
+ },
95
+ props: {
96
+ modelValue: {
97
+ type: Boolean ,
98
+ default: false ,
99
+ },
100
+ info: {
101
+ type: String ,
102
+ required: true ,
103
+ },
104
+ },
105
+
106
+ computed: {
107
+ value: {
108
+ get () {
109
+ return this .modelValue
110
+ },
111
+ set (val ) {
112
+ this .$emit (' update:modelValue' , val)
113
+ },
114
+ },
115
+ },
116
+ }
117
+ ```
118
+ :::
119
+
120
+ )))
121
+
82
122
83
123
Now launch the dialog from any component of your app:
84
124
125
+ ))) method-switch
126
+
127
+ ::: vue-slot composition
128
+ ``` js
129
+ import { dialogInjectionKey } from ' gitart-vue-dialog'
130
+ const InfoDialog = defineAsyncComponent (() => import (' @/components/InfoDialog.vue' ))
131
+
132
+ export default {
133
+ setup () {
134
+ const {
135
+ addDialog ,
136
+ } = inject (dialogInjectionKey)
137
+
138
+ const onOpenInfo = () => {
139
+ addDialog ({
140
+ component: InfoDialog,
141
+ props: {
142
+ info: ' Info to display' ,
143
+ },
144
+ })
145
+ }
146
+
147
+ return {
148
+ onOpenInfo,
149
+ }
150
+ },
151
+ }
152
+ ```
153
+ :::
154
+
155
+ ::: vue-slot option
85
156
``` js
86
157
const InfoDialog = defineAsyncComponent (() => import (' @/components/InfoDialog.vue' ))
87
158
@@ -97,4 +168,7 @@ export default {
97
168
},
98
169
},
99
170
}
100
- ```
171
+ ```
172
+ :::
173
+
174
+ )))
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<Component
3
- :is =" modal .component"
4
- v-for =" (modal , index) in dialogs"
5
- :key =" modal .id"
6
- v-bind =" modal .props"
3
+ :is =" dialog .component"
4
+ v-for =" (dialog , index) in dialogs"
5
+ :key =" dialog .id"
6
+ v-bind =" dialog .props"
7
7
@update:modelValue =" onClose(index)"
8
8
/>
9
9
</template >
You can’t perform that action at this time.
0 commit comments