-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
Description
- I have searched the issues of this repository and believe that this is not a duplicate.
Version
1.3.10
Environment
macOS10.14 chrome75 Vue2.6.10
Reproduction link
Steps to reproduce
// 自定义组件 HelloWorld.vue
<a-form :form="form">
<a-form-item>
<a-input v-decorator="['inputValue']"/>
</a-form-item>
</a-form>// 父组件 自定义directive
<template>
<a-form :form="form">
<a-form-item>
<hello-world v-clearData></hello-world>
</a-form-item>
</a-form>
</template>// FormItem.js
function decoratorOption(vnode) {
if (vnode.data && vnode.data.directives) {
var directive = find(vnode.data.directives, ['name', 'decorator']); // 取到的directive为undefined,因为此时的directives是包含 自定义组件v-clearData的
warning(!directive || directive && Array.isArray(directive.value), 'Invalid directive: type check failed for directive "decorator". Expected Array, got ' _typeof(directive.value) '. At ' vnode.tag '.'); // 导致directive.value报错
return directive ? directive.value : null;
} else {
return null;
}
}What is expected?
warning(!directive || directive && Array.isArray(directive.value), 'Invalid directive: type check failed for directive "decorator". Expected Array, got ' _typeof(directive.value) '. At ' vnode.tag '.');期望当directive为undefined时,_typeof(directive.value) 做兼容
What is actually happening?
TypeError: Cannot read property 'value' of undefined at VueComponent.decoratorOption
在全局定义了自定义directive时