1.Vue有更好的渲染优化:
React中当某个组件发生变化时,会以该节点为根,重新渲染所有的子组件,如果要避免子组件的重新渲染,可以在生命周期函数shouldComponentUpdate中进行设置。
Vue能自动追踪数据依赖,只渲染需要更新的子组件。
2.数据绑定:
Vue具有双向绑定语法糖,具有双向数据绑定,react中是单向数据流,但是也可以实现双向数据绑定。
3.React中通过js来编写jsx,而Vue通过模板引擎来处理html、css和js
旧版React生命周期
挂载阶段:
1.componentWillMount
2.render
3.componentDidMount
更新阶段:
1.componentWillReceiveProps(如果是state更新就没有这步)
2.shouldComponentUpdate
3.componentWillUpdate
4.render
5.componentDidUpdate
卸载阶段:
1.componentWillUnmount
新版React生命周期
挂载阶段:
1.constructor
2.getDerivedStateFromProps
3.render
4.componentDidMount
更新阶段:
1.getDerivedStateFromProps
2.shouldComponentUpdate
3.render
4.getSnapshotBeforeUpdate
卸载阶段:
1.componentWillUnmount
React中class和函数组件生命周期:
Vue中的生命周期
beforeCreate
created
beforeMount
mounted
beforeUpdate
updated
beforeDestory
destoryed