请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

正在回答 回答被采纳积分+3

3回答

yuexiaqingmiao 2022-08-04 12:55:29

可以放,以前记得react的文档里面有提到说只是一种提案。现在的react文档中已经放了一个mdn的链接

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Public_class_fields#public_instance_fields

`If calling bind annoys you, there are two ways you can get around this. You can use public class fields syntax to correctly bind callbacks` --- https://reactjs.org/docs/handling-events.html


0 回复 有任何疑惑可以回复我~
慕粉3871079 2021-02-24 14:47:29

我试过是可以用的,但是规范上来讲,定义的变量还是写在构造函数里吧

0 回复 有任何疑惑可以回复我~
双越 2020-08-22 20:10:04

直接在 class 中写 state={...} 那是静态属性,不是实例属性。

0 回复 有任何疑惑可以回复我~
  • 直接写 state={...} 也是实例属性,和写在 constructor 中没区别,如果加上 static 关键字才是静态属性。
    回复 有任何疑惑可以回复我~ 2020-09-29 18:01:38
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号