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

父组件实现子组件自定义事件包含setState,e.stopPropagation不生效 #8582

Closed
zhcode-fun opened this issue Jan 26, 2021 · 1 comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@zhcode-fun
Copy link

相关平台

微信小程序

复现仓库

https://github.com/zhcode-fun/taro-propagation-demo
小程序基础库: 2.14.4
使用框架: React

复现步骤

  1. 运行代码之后,点击子组件按钮,看打印
  2. 把父组件中的setState一行注释,再点击看打印
  // 实现子组件的自定义事件
  testChange() {
    console.log('触发了---------------');
    this.setState({});  // 此行注释,则 e.stopPropagation 正常
  }

  // 父节点事件
  onFather() {
    console.log('冒泡了-----------');
  }

期望结果

e.stopPropagation正常工作

实际结果

当自定义事件中包含this.setState({}),e.stopPropagation不生效

环境信息

👽 Taro v3.0.25


  Taro CLI 3.0.25 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 14.15.1 - C:\Program Files\nodejs\node.EXE
      npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jan 26, 2021
@zhcode-fun
Copy link
Author

已用此办法解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

1 participant