Skip to content

[Vue warn]: Invalid prop: type check failed for prop "onChange". Expected Function, got Array #3933

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
w18701660942 opened this issue Apr 13, 2021 · 12 comments
Labels
🤔 Need Reproduce We cannot reproduce your problem outdated

Comments

@w18701660942
Copy link

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

Version

2.1.1

Environment

开发

Reproduction link

http://localhost:8090/country/country_list

Steps to reproduce

开发2次组件时,只要加chang事件就报[Vue warn]: Invalid prop: type check failed for prop "onChange". Expected Function, got Array

What is expected?

能正常使用

What is actually happening?

能正常使用


<script lang="ts"> import { useEmits, useProps } from '@/hooks' import { defineComponent, ref } from 'vue' const plainOptions = ['Apple', 'Pear', 'Orange'] export default defineComponent({ props: { ...useProps(), value: Array, }, emits: ['update:value'], setup(props, ctx) { const { emit } = ctx const change = (checkedValue: any) => { emit('update:value',checkedValue) } return { change, plainOptions, value1: ref([]) } } }) </script>
@w18701660942
Copy link
Author

image

@w18701660942
Copy link
Author

image

@John60676 John60676 added the 🤔 Need Reproduce We cannot reproduce your problem label Apr 13, 2021
@github-actions
Copy link

Hello @w18701660942. Please provide a online reproduction by forking this link for vue2link for vue3 or a minimal GitHub repository. Make sure to choose the correct version.

你好 @w18701660942, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 for vue2此处 for vue3 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。请确保选择准确的版本。

@w18701660942
Copy link
Author

我自己找到解决方法了,用emits重写一下,覆盖原来的方法就行,建议不要合并成数组

@github-actions
Copy link

Since the issue was labeled with Need Reproduce, but no response in 7 days. This issue will be closed. If you have any questions, you can comment and reply.

由于该 issue 被标记为需要复现信息,却 7 天未收到回应。现关闭 issue,若有任何问题,可评论回复。

@idonteatcookie
Copy link

我自己找到解决方法了,用emits重写一下,覆盖原来的方法就行,建议不要合并成数组

遇到同样的问题了 能详细说一下怎么解决的吗?谢谢!:D

@idonteatcookie
Copy link

我自己找到解决方法了,用emits重写一下,覆盖原来的方法就行,建议不要合并成数组

哦 我懂了 emits:['change'] 这样…… 打扰了 :P

@GZ0759
Copy link

GZ0759 commented Feb 23, 2022

我自己找到解决方法了,用emits重写一下,覆盖原来的方法就行,建议不要合并成数组

哦 我懂了 emits:['change'] 这样…… 打扰了 :P

为什么会这样呢,我在setup中的emits添加 change 也不报警告了

@passioncsu
Copy link

请先允许我哭会, 刚开始用的"ant-design-vue": "3.1.0-rc.1"报这个告警, 然后更新为当前最新 "ant-design-vue": "3.1.0-rc.5" 还是报这个告警,虽然不影响使用,但是对于强迫症来说必须消除告警. 这个描述真的太隐晦了. 对于小白的我没看懂.

总之就是 在组件里面声明一下change的这个emit就好了, 底层原因没深究真的有点迷.

如下这么写一下就不告警了, 希望帮到别人.

<script lang="ts" setup> const emit = defineEmits(['update:modelValue', 'change']); <script>

@RSS1102
Copy link

RSS1102 commented Aug 12, 2022

请先允许我用的哭会-vue-vue-vue.1.1.1”最新消息,然后刚开始更新为当前ant-design-vue.0”最新消息,然后更新:“ant-design-v”:“3.1.0- 5" 还是报这个热门话题。虽然不影响使用,但必须要热门话题。这个描述真的太隐晦了。对于小白的我没看懂。

那就是在组件里面声明一下改变的这个放出来就好了,动力原因没深究真的有点迷。

就这样写一下,别想了,希望帮到你

<script lang="ts" setup> const emit = defineEmits(['update:modelValue', 'change']); <脚本>

thanks,我也遇到了这个问题,通过你的方法解决了。我是将upload挂在到vue实例上之后产生的这个错误。而且事件被判定为ArraynotFunction,而导致不能使用。

@RSS1102
Copy link

RSS1102 commented Aug 12, 2022

Function

那个问题好像是有一个拦截他的change事件然后分配给传过来的参数,来指定子传父触发的方法。你通过重新定义了@change默认事件传递之后,就不会走他拦截的那个方法了(个人认为是这样的。)

@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 Aug 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤔 Need Reproduce We cannot reproduce your problem outdated
Projects
None yet
Development

No branches or pull requests

6 participants