V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  xbrave  ›  全部回复第 1 页 / 共 1 页
回复总数  3
2020-08-04 11:18:22 +08:00
回复了 6234127 创建的主题 Apple 安卓手机能使用 Airpods Pro 么, 效果咋样呢
Airpods Pro 你就当是一个普通的蓝牙耳机,哪个系统的手机都能用
建议阅读 React 文档官网上的 handling Events 这一节:https://reactjs.org/docs/handling-events.html
You have to be careful about the meaning of this in JSX callbacks. In JavaScript, class methods are not bound by default. If you forget to bind this.handleClick and pass it to onClick, this will be undefined when the function is actually called.

This is not React-specific behavior; it is a part of how functions work in JavaScript. Generally, if you refer to a method without () after it, such as onClick={this.handleClick}, you should bind that method.

If calling bind annoys you, there are two ways you can get around this. If you are using the experimental public class fields syntax, you can use class fields to correctly bind callbacks
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4024 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 05:19 · PVG 13:19 · LAX 21:19 · JFK 00:19
Developed with CodeLauncher
♥ Do have faith in what you're doing.