作者harryfly (波特)
看板Ajax
标题[问题] React Native的State
时间Sat Jun 24 19:48:29 2017
是这样的
我最近刚开始学习RN
同时JS也是刚接触
在官方的教学文件中
有关State的一部分我一直搞不太懂
http://facebook.github.io/react-native/docs/state.html
class Blink extends Component {
constructor(props) {
super(props);
在class一开始 做初始化props的动作
左括号之後是属性的设定吧?
那我不懂的是super(props)这一行
super应该是拿来呼叫父类别的成员 or 建构式
那麽这一行是呼叫 Component 的Component(props)方法?
为什麽要这麽做呢 有甚麽用途??
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 36.225.26.18
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Ajax/M.1498304912.A.DA5.html
※ 编辑: harryfly (36.225.26.18), 06/24/2017 19:50:29
1F:→ MangoTW: constructor() 06/24 23:23
所以super(props)单纯只是一个初始化必须要有的东西 因为没有就会error是吗
※ 编辑: harryfly (36.225.26.18), 06/25/2017 04:59:52
2F:推 jackblack: Component 初始化要用,你的 Blink 继承了 Component 06/25 13:39
懂了 感恩
※ 编辑: harryfly (36.225.26.18), 06/26/2017 09:37:19