1.默认状态设置

1.constructor (ES6)

constructor(props) {
this.state = {
n: ...
}
}

2.getInitialState (ES5)

只能用在React.createClass中,extends React.Component不行

2.默认props设置

1.组件外部 (ES6)

component.defaultProps = {
name: '...'
}

2.组件内部 (ES7,必须开启ES7的babel支持)

static defaultProps = {
name: '...'
}

3. getDefaultProps (ES5)

只能用在React.createClass中,extends React.Component不行

最新文章

  1. 关于C#消息调度(作业日志)
  2. 【Spring】非Spring IOC容器下获取Spring IOC上下文的环境
  3. C++调用约定和名字约定
  4. MySQL Workbench “Error Code: 1175” 的解决方法
  5. win7远程桌面恢复全屏状态快捷键
  6. [XAF] How to use the Allow/Deny permissions policy in the existing project
  7. [SoapUI] 同一个Resource不同参数时,在两个step里默认打开总是同一个Resource
  8. iOS常用宏 定义
  9. 高效的两段式循环缓冲区──BipBuffer
  10. 【关于HBITMAP, DC, MEM DC, Clipboard】将HBITMAP拷贝到Clipboard(Windows Clipboard & OLE Clipboard)
  11. <mvc:annotation-driven />
  12. 简易nagios安装
  13. (Problem 62)Cubic permutations(待续)
  14. 配置python+mod_wsgi+apache 时 在浏览器中访问服务器时报错:Invalid HTTP_HOST header: 'XXXXX'. You may need to add u'XXXXX' to ALLOWED_HOSTS,在setting.py中添加‘*”无效的原因
  15. linux_rsync定时备份
  16. 16进制转化8进制---map
  17. 如何从零开始系统化学习视觉SLAM?
  18. leetcode-1-TwoNums
  19. 设计模式之Prototype
  20. windows命令启动mysql

热门文章

  1. 在nginx环境下,直接用域名访问(首页)
  2. Linux命令应用大词典-第44章 PPPoE配置
  3. 韦大仙--python对文件操作
  4. 韦大仙python--购物车
  5. 树莓派 Raspberry Pi 与 micro:bit起手式
  6. javac 编译过程
  7. (Pyhton爬虫03)爬虫初识
  8. 【20180807模拟测试】tree
  9. 【shell 练习3】用户管理脚本(一)
  10. nodejs笔记--与Redis的交互篇(六)