增加非显式属性和快速定义

pull/1/head
yutent 2023-08-07 18:56:41 +08:00
parent da056ae47f
commit f9e766ab4a
1 changed files with 20 additions and 0 deletions

View File

@ -78,6 +78,26 @@ function getType(v) {
? { type: Array, default: v } ? { type: Array, default: v }
: { type: Object, default: v } : { type: Object, default: v }
case 'string':
let type = String
let attribute = true
if (v.includes('!')) {
v = v.split('!')
let _t = v.shift()
if (_t === 'str') {
v = v.join('!')
} else if (_t === 'num') {
type = Number
v = +v.shift() || 0
} else if (_t === 'bool') {
type = Boolean
v = v.shift()
v = v !== 'false' && v !== ''
}
attribute = false
}
return { type, default: v, attribute }
default: default:
return { type: String, default: v + '' } return { type: String, default: v + '' }
} }