Skip to content

Commit 27e7e50

Browse files
committed
fix(components): support multi prop type, closes #1414
1 parent 59c6641 commit 27e7e50

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

packages/app-backend-vue2/src/components/data.ts

+3
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ const fnTypeRE = /^(?:function|class) (\w+)/
150150
* Convert prop type constructor to string.
151151
*/
152152
function getPropType (type) {
153+
if (Array.isArray(type)) {
154+
return type.map(t => getPropType(t)).join(' or ')
155+
}
153156
const match = type.toString().match(fnTypeRE)
154157
return typeof type === 'function'
155158
? (match && match[1]) || 'any'

packages/app-backend-vue3/src/components/data.ts

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ const fnTypeRE = /^(?:function|class) (\w+)/
6767
* Convert prop type constructor to string.
6868
*/
6969
function getPropType (type) {
70+
if (Array.isArray(type)) {
71+
return type.map(t => getPropType(t)).join(' or ')
72+
}
7073
const match = type.toString().match(fnTypeRE)
7174
return typeof type === 'function'
7275
? (match && match[1]) || 'any'

packages/shell-dev-vue3/src/NativeTypes.vue

+7
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ export default {
7676
}
7777
},
7878
79+
props: {
80+
multiTypeProp: {
81+
type: [Date, Boolean],
82+
default: false
83+
}
84+
},
85+
7986
data () {
8087
return {
8188
localDate: new Date(),

0 commit comments

Comments
 (0)