vue2 和 vue3的区别

58 阅读1分钟

1 双向数据绑定原理不同 vue2 使用Object.defineProperty()进行数据劫持,结合发布订阅模式 vue3 使用Proxy反射

2 vue2使用 option API vue3使用 composition API

3 vue3支持fragment(组件中可以放置多个节点)

4 vue3支持Teleport瞬移组件

5 父子传参方式不同

6 生命周期不同 vue2:

beforeCreate              setup
Created                   setup
beforeMounte              onBeforeMount
Mounted                   onMounted
beforeUpdate              onBeforeUpdate
updated                   onUpdated
beforeDestroy             onBeforeUnmout
destroyed                 onUnmouted

activated                 onActivated
deactivated               onDeactivated