Appearance
vue
- beforeCreate ( <=初始化事件和生命周期)
- created (<= prop 注入完成)
- beforeMount 编译 template 模板或者 render, 并收集依赖
- mouted (挂载到 dom 上面)
- beforeUpdate => 不能在里面更新 data => 开始 diff render
- beforeDestory => 解除绑定,解除事件,销毁子组件。
- destoryed => 删除完回调
react
初始化阶段
- defaultProp => prop
- initState
- componentWillMount
- render
- componentDidMount
运行阶段
react 的变化需要自己手动更新,包括 props 和 state 的变化
- props 变化通过 componentWillReceiveProps 获得,
- state 的变化通过 setState 方法来实现
均会触发 shouldComponentUpdate 钩子,如果钩子返回 false 表示不更新。
然后会触发 componentWillUpdate 构造
重新调用 render 函数, 渲染界面
触发 componentDidUpdate 钩子,
销毁钩子 componentWillUnmount
