Back
VueEasyNew
What is Vue 3 and how does it differ from Vue 2?
Think about the rewrite, reactivity engine, and API styles
Ideal Answer
Vue 3 is a full rewrite of Vue.js focused on performance, smaller bundle size, and better TypeScript support. Key differences from Vue 2:
- Reactivity: Uses ES6
Proxyinstead ofObject.defineProperty, enabling reactivity for property addition/deletion and array index/length changes. - Composition API: New
setup()/<script setup>style for organizing logic by feature instead of by option type. - Multiple root nodes (Fragments): Templates no longer require a single root element.
- Teleport: Render content outside the component's DOM hierarchy.
- Suspense: Built-in support for async component trees.
- Better TS support: Rewritten in TypeScript.
- Smaller/faster: Tree-shakeable APIs and a rewritten virtual DOM with compiler-informed optimizations (patch flags).