chore: fix getProps bug
							parent
							
								
									57698010f7
								
							
						
					
					
						commit
						3837493567
					
				|  | @ -1,5 +1,10 @@ | ||||||
| import isPlainObject from 'lodash/isPlainObject' | import isPlainObject from 'lodash/isPlainObject' | ||||||
| 
 | 
 | ||||||
|  | function getType (fn) { | ||||||
|  |   const match = fn && fn.toString().match(/^\s*function (\w+)/) | ||||||
|  |   return match ? match[1] : '' | ||||||
|  | } | ||||||
|  | 
 | ||||||
| const camelizeRE = /-(\w)/g | const camelizeRE = /-(\w)/g | ||||||
| const camelize = (str) => { | const camelize = (str) => { | ||||||
|   return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') |   return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') | ||||||
|  | @ -67,8 +72,11 @@ const getOptionProps = (instance) => { | ||||||
|     const props = (Ctor.options || {}).props || {} |     const props = (Ctor.options || {}).props || {} | ||||||
|     const res = {} |     const res = {} | ||||||
|     for (const [k, v] of Object.entries(props)) { |     for (const [k, v] of Object.entries(props)) { | ||||||
|       if (v.default !== undefined) { |       const def = v.default | ||||||
|         res[k] = typeof v.default === 'function' ? v.default() : v.default |       if (def !== undefined) { | ||||||
|  |         res[k] = typeof def === 'function' && getType(v.type) !== 'Function' | ||||||
|  |           ? def.call(instance) | ||||||
|  |           : def | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     return { ...res, ...propsData } |     return { ...res, ...propsData } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 tjz
						tjz