-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
自定义组件的自定义方法传多参数 #2132
Labels
bug
Something isn't working
Comments
你确认这个写法 |
zhetengbiji
added a commit
that referenced
this issue
Sep 24, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
uni-app 转 微信小程序
![image](https://user-images.githubusercontent.com/16641120/93730758-9a765c80-fbfc-11ea-8e8e-8c710b9273f0.png)
![image](https://user-images.githubusercontent.com/16641120/93730813-e0332500-fbfc-11ea-850f-288f1b14f2ed.png)
![image](https://user-images.githubusercontent.com/16641120/93730837-f214c800-fbfc-11ea-945d-db85fcd5c357.png)
![image](https://user-images.githubusercontent.com/16641120/93730927-77987800-fbfd-11ea-8298-ced0579513d5.png)
自定义组件的自定义方法 调用函数组装多参数问题。
额外参数为 父组件上绑定的数据是没有问题的,在如v-for :for-item 参数才会有问题
问题描述
一个自定义组件:
父组件调用自定义组件(CheckableTag):
执行,打印输出:
true
undefined
参数option 没有传过来,查看编译结果:
option
参数指向错误。怀疑是
![image](https://user-images.githubusercontent.com/16641120/93731371-3acd8080-fbff-11ea-9cb3-fde1522663fe.png)
@change="(checked) => handleChange(checked, option)"
语句箭头函数的原因,改为:
@change="function (checked) { handleChange(checked, option) }"
handleChange 方法输出结果:undefined
{label: "10km内", value: "10km"}
参数
checked
又不存在了,十分不解,各种调试之后发现只要在handleChange(checked, option)
随便加一条或多条语句就正常了,如:这样达到想要的结果,两个参数都传过来了。
查看编译结果发现,这里多条语句与单条语句的编译结果是不一样的:
单语句:
多语句:
多语句与箭头函数形式的写法类似都会提取成单独的方法来调用。
系统信息:
补充信息
代码编译可能存在问题
The text was updated successfully, but these errors were encountered: