Skip to content

Commit

Permalink
fix(components): support multi prop type, closes #1414
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed May 6, 2021
1 parent 59c6641 commit 27e7e50
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/app-backend-vue2/src/components/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ const fnTypeRE = /^(?:function|class) (\w+)/
* Convert prop type constructor to string.
*/
function getPropType (type) {
if (Array.isArray(type)) {
return type.map(t => getPropType(t)).join(' or ')
}
const match = type.toString().match(fnTypeRE)
return typeof type === 'function'
? (match && match[1]) || 'any'
Expand Down
3 changes: 3 additions & 0 deletions packages/app-backend-vue3/src/components/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ const fnTypeRE = /^(?:function|class) (\w+)/
* Convert prop type constructor to string.
*/
function getPropType (type) {
if (Array.isArray(type)) {
return type.map(t => getPropType(t)).join(' or ')
}
const match = type.toString().match(fnTypeRE)
return typeof type === 'function'
? (match && match[1]) || 'any'
Expand Down
7 changes: 7 additions & 0 deletions packages/shell-dev-vue3/src/NativeTypes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ export default {
}
},
props: {
multiTypeProp: {
type: [Date, Boolean],
default: false
}
},
data () {
return {
localDate: new Date(),
Expand Down

0 comments on commit 27e7e50

Please sign in to comment.