Skip to content
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

父组件向子组件传函数,子组件能调用, 但是没有返回值 #2286

Closed
Lionad-Morotar opened this issue Feb 28, 2019 · 6 comments
Labels
question Further information is requested

Comments

@Lionad-Morotar
Copy link

问题描述
父组件向子组件传函数,子组件能调用, 但是没有返回值

复现步骤
** 1 父组件模板 **
image
** 2 父组件函数 **
image
** 3 子组件onClick时执行某函数调用父组件函数 **
image
** 4 子组件函数执行结果 **
image

系统信息

  Taro CLI 1.2.13 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 10.15.1 - C:\Program Files\nodejs\node.EXE
      npm: 6.8.0 - C:\Program Files\nodejs\npm.CMD
@taro-bot
Copy link

taro-bot bot commented Feb 28, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@Chen-jj
Copy link
Contributor

Chen-jj commented Feb 28, 2019

@Lionad-Morotar 小程序端 props 传函数是利用小程序的 triggerEvent 机制实现的,triggerEvent 只能调用父组件函数,不能获取父组件函数的返回值。

目前我们正在改进小程序的 props 实现,完成后即可拿到返回值,但仍需要一段时间。

你可以先把需要 return 的内容改为 setState,通过 props 传给子组件。

@Chen-jj Chen-jj added question Further information is requested answered labels Feb 28, 2019
@taro-bot
Copy link

taro-bot bot commented Feb 28, 2019

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

@Lionad-Morotar
Copy link
Author

🆗

@guxingke201
Copy link
Contributor

v1.3.0-beta.3貌似没处理
@Chen-jj 预计啥时候会安排处理呢?

@Chen-jj
Copy link
Contributor

Chen-jj commented May 23, 2019

@guxingke201 v1.3.0-beta 已经可以拿到父组件函数调用的返回值

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants