mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-09 04:31:35 +08:00
fix(select): support functional component in some utils
This commit is contained in:
parent
8fcedef72c
commit
b7c13912f5
@ -8,6 +8,12 @@ function isDropdownRelatedComponent (vNode) {
|
||||
}
|
||||
|
||||
function getComponentNameOf (vNode) {
|
||||
/**
|
||||
* Functional component
|
||||
*/
|
||||
if (vNode.fnOptions && vNode.fnOptions.name) {
|
||||
return vNode.fnOptions.name
|
||||
}
|
||||
if (
|
||||
vNode.componentOptions &&
|
||||
vNode.componentOptions.Ctor &&
|
||||
@ -30,7 +36,13 @@ function getSlotOf (componentInstance, slotName) {
|
||||
}
|
||||
|
||||
function getOptionPropsDataOf (vNode) {
|
||||
const propsData = vNode.componentOptions.propsData || {}
|
||||
/**
|
||||
* Functional component
|
||||
*/
|
||||
const propsData =
|
||||
(vNode.componentOptions && vNode.componentOptions.propsData) ||
|
||||
vNode.data.props ||
|
||||
{}
|
||||
if (!isDropdownRelatedComponent(vNode)) {
|
||||
/**
|
||||
* Select Option
|
||||
@ -42,7 +54,7 @@ function getOptionPropsDataOf (vNode) {
|
||||
try {
|
||||
propsData.label = vNode.componentOptions.children[0].text.trim()
|
||||
} catch (err) {
|
||||
console.error(['naive-ui/select-option: Select Option only accept pure text as children.'])
|
||||
console.error(['[naive-ui/select-option]: Select Option only accept pure text as children.'])
|
||||
propsData.label = null
|
||||
}
|
||||
} else if (propsData.value) {
|
||||
|
Loading…
Reference in New Issue
Block a user