Vue2.x和Vue3.x有什么区别?
Vue2.x和Vue3.x有什么区别?
1、重构响应式系统,使用 Proxy
替换 Object.defineProperty
,使用 Proxy
优势:
Object.defineProperty
一样遍历每个属性,有一定的性能提升apply
、ownKeys
、has
等13种方法,而 Object.defineProperty
不行2、新增Composition API,更好的逻辑复用和代码组织
slot
优化,将 slot
编译为 lazy
函数,将 slot
的渲染的决定权交给子组件3、代码结构调整,更便于Tree shaking,使得体积更小
4、使用Typescript替换Flow