难道要加--harmony_arrow_functions 才能吗?但是我是用命令来启动RN,怎么加上呢?
|
WildCatMar 9, 2016
1
不需要加吧, react native 用 babel
|
|
2
@WildCat
onPress={ ()=> setState({name:'xx'})} .. 我这样写会报 setState 不是函数。 arrow function 应该不用 bind this 吧。 |
|
WildCatMar 9, 2016
3
this.setState()
绝对不会是直接 setState |
|
yyfearthMar 9, 2016
5
@123s 肯定要加 this 啊
arrow function 应该不用 bind this 的意思是 这函数本身没有 this 它的 this 是外面 function 的 this 但不等于说可以把 this 省略 除非你用 with statement 否则不存在可以省略 this 的情况 |
|
neoblackcapMar 9, 2016
6
@yyfearth 应该说箭头函数的 this 跟包围它的的代码块里面的 this 是共享的吧。毕竟说没有 this 其他初学者可能会以为 this 变量就不能用了。
|