Skip to content

按需引入时,a-select-option报错问题 #2497

@zyqwst

Description

@zyqwst
  • I have searched the issues of this repository and believe that this is not a duplicate.

Environment

vue: v2.6.11;chrome浏览器 83.0.4103.116(正式版本) (64 位)

Reproduction link

https://github.com/vueComponent/ant-design-vue

Steps to reproduce

按需引入组件并使用a-select组件;
配置:

"babel-plugin-import": "^1.13.0"
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
],
plugins: [
[
"import",
{
libraryName: "ant-design-vue",
libraryDirectory: "es",
"style": true
}
]
]
}

在vue组件中使用select组件

<a-select default-value="lucy" style="width: 120px" @change="handleChange">
<a-select-option value="jack">
Jack
</a-select-option>
<a-select-option value="lucy">
Lucy
</a-select-option>
<a-select-option value="disabled" disabled>
Disabled
</a-select-option>
<a-select-option value="Yiminghe">
yiminghe
</a-select-option>
</a-select>

What is expected?

在components中再引入Option即可修复该问题。但是这也太坑了,完全没有文档支持
components: {ASelect:Select,ASelectOption:Select.Option}

What is actually happening?

vue.runtime.esm.js?17dc:619 [Vue warn]: Error in data(): "TypeError: Cannot read property 'children' of undefined"

found in

---> <Select>
<ASelect>
<JsonSchemaEditor> at packages/json-schema-editor/main.vue
<App> at examples/App.vue
<Root>
warn @ vue.runtime.esm.js?17dc:619
logError @ vue.runtime.esm.js?17dc:1884
globalHandleError @ vue.runtime.esm.js?17dc:1879
handleError @ vue.runtime.esm.js?17dc:1839
getData @ vue.runtime.esm.js?17dc:4750
initData @ vue.runtime.esm.js?17dc:4705
initState @ vue.runtime.esm.js?17dc:4642
Vue._init @ vue.runtime.esm.js?17dc:5006
VueComponent @ vue.runtime.esm.js?17dc:5154
createComponentInstanceForVnode @ vue.runtime.esm.js?17dc:3283
init @ vue.runtime.esm.js?17dc:3114
createComponent @ vue.runtime.esm.js?17dc:5978
createElm @ vue.runtime.esm.js?17dc:5925
patch @ vue.runtime.esm.js?17dc:6477
Vue._update @ vue.runtime.esm.js?17dc:3945
updateComponent @ vue.runtime.esm.js?17dc:4066
get @ vue.runtime.esm.js?17dc:4479
Watcher @ vue.runtime.esm.js?17dc:4468
mountComponent @ vue.runtime.esm.js?17dc:4073
Vue.$mount @ vue.runtime.esm.js?17dc:8415
init @ vue.runtime.esm.js?17dc:3118
createComponent @ vue.runtime.esm.js?17dc:5978
createElm @ vue.runtime.esm.js?17dc:5925
createChildren @ vue.runtime.esm.js?17dc:6053
createElm @ vue.runtime.esm.js?17dc:5954
patch @ vue.runtime.esm.js?17dc:6477
Vue._update @ vue.runtime.esm.js?17dc:3945
updateComponent @ vue.runtime.esm.js?17dc:4066
get @ vue.runtime.esm.js?17dc:4479
Watcher @ vue.runtime.esm.js?17dc:4468
mountComponent @ vue.runtime.esm.js?17dc:4073
Vue.$mount @ vue.runtime.esm.js?17dc:8415
init @ vue.runtime.esm.js?17dc:3118
createComponent @ vue.runtime.esm.js?17dc:5978
createElm @ vue.runtime.esm.js?17dc:5925
createChildren @ vue.runtime.esm.js?17dc:6053
createElm @ vue.runtime.esm.js?17dc:5954
patch @ vue.runtime.esm.js?17dc:6477
Vue._update @ vue.runtime.esm.js?17dc:3945
updateComponent @ vue.runtime.esm.js?17dc:4066
get @ vue.runtime.esm.js?17dc:4479
Watcher @ vue.runtime.esm.js?17dc:4468
mountComponent @ vue.runtime.esm.js?17dc:4073
Vue.$mount @ vue.runtime.esm.js?17dc:8415
init @ vue.runtime.esm.js?17dc:3118
createComponent @ vue.runtime.esm.js?17dc:5978
createElm @ vue.runtime.esm.js?17dc:5925
patch @ vue.runtime.esm.js?17dc:6516
Vue._update @ vue.runtime.esm.js?17dc:3945
updateComponent @ vue.runtime.esm.js?17dc:4066
get @ vue.runtime.esm.js?17dc:4479
Watcher @ vue.runtime.esm.js?17dc:4468
mountComponent @ vue.runtime.esm.js?17dc:4073
Vue.$mount @ vue.runtime.esm.js?17dc:8415
eval @ main.js?c31f:15
./examples/main.js @ index.js:986
__webpack_require__ @ index.js:849
fn @ index.js:151
1 @ index.js:1185
__webpack_require__ @ index.js:849
checkDeferredModules @ index.js:46
(anonymous) @ index.js:925
(anonymous) @ index.js:928
Show 33 more frames
vue.runtime.esm.js?17dc:1888 TypeError: Cannot read property 'children' of undefined
at getPropValue (util.js?4378:36)
at VueComponent.getLabelFromOption (Select.js?f898:253)
at eval (Select.js?f898:265)
at Array.forEach (<anonymous>)
at VueComponent.getOptionsInfoFromProps (Select.js?f898:260)
at VueComponent.data (Select.js?f898:116)
at getData (vue.runtime.esm.js?17dc:4748)
at initData (vue.runtime.esm.js?17dc:4705)
at initState (vue.runtime.esm.js?17dc:4642)
at VueComponent.Vue._init (vue.runtime.esm.js?17dc:5006)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions