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

1.3.11版本微信小程序button组件事件绑定异常 #4022

Closed
EickeOe opened this issue Jul 31, 2019 · 7 comments
Closed

1.3.11版本微信小程序button组件事件绑定异常 #4022

EickeOe opened this issue Jul 31, 2019 · 7 comments
Labels
question Further information is requested

Comments

@EickeOe
Copy link

EickeOe commented Jul 31, 2019

问题描述
微信小程序,一个页面存在两个按钮,两个按钮的css定位都设置为position: inherit;,绑定不同的click事件,则两个按钮click时触发的事件都为最后一个按钮绑定的事件

<View className="first">
          <Button className="text" onClick={() => console.log(1)}>
            1
          </Button>
        </View>
        <View className="last">
          <Button className="text" onClick={() => console.log(2)}>
            2
          </Button>
</View>
.text{
  position: inherit;
}

期望行为
按钮click事件正常调用

系统信息

  • 操作系统: [e.g. Windows 10]
  • Taro 版本 [e.g. v.1.3.11]
  • Node.js 版本 [e.g. v9.0.0]
  • 报错平台 [h5, weapp]
@taro-bot
Copy link

taro-bot bot commented Jul 31, 2019

欢迎提交 Issue~

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

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

Good luck and happy coding~

@yuche
Copy link
Contributor

yuche commented Jul 31, 2019

单单这段代码还是没法复现,你可以把整个组件的代码一起贴出来

@EickeOe
Copy link
Author

EickeOe commented Jul 31, 2019

@yuche 按钮的样式设置为position: inherit;,就出现了问题

@yuche
Copy link
Contributor

yuche commented Jul 31, 2019

你有没有其他小程序(例如百度/字节跳动)可以试一下

@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 31, 2019

@EickeOe 自己看看 Button 组件的默认样式,就能知道为什么了。

image

@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 31, 2019

答案:Button 的 after 伪类是 position absolute 的,你把 Button 改静态定位了,第二个按钮边框就覆盖整个页面,你按哪里都触发按钮二的 onClick,就这么简单一个样式问题。

@Chen-jj Chen-jj closed this as completed Jul 31, 2019
@Chen-jj Chen-jj added answered question Further information is requested labels Jul 31, 2019
@EickeOe
Copy link
Author

EickeOe commented Jul 31, 2019

@Chen-jj 解决了,谢谢大佬

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