Skip to content

FormItem中当定义自定义directive时报错 #972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
wd2010 opened this issue Jul 16, 2019 · 2 comments
Closed
1 task done

FormItem中当定义自定义directive时报错 #972

wd2010 opened this issue Jul 16, 2019 · 2 comments
Labels

Comments

@wd2010
Copy link

wd2010 commented Jul 16, 2019

  • 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

Edit on CodeSandbox

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时

@tangjinzhou
Copy link
Member

ref #930

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants