一、vue3新特性
1⃣️ same small size、import only what you need
2⃣️ Boosted performance(faster rendering)
a. Rewritten Virtual Dom.
b. Improve Diffing Algorithm.
3⃣️ options API -> compositon API
4⃣️ enhanced Ts support(optional)
5⃣️ multi-root components
更多详情查看 Vue3 Deep Dive.
二、安装
// 脚手架 Vite: npm init vite-app hello-vue3 # OR yarn create vite-app hello-vue3 // 脚手架 vue-cli: npm install -g @vue/cli # OR yarn global add @vue/cli vue create hello-vue3 # select vue 3 preset
三、具体新特性细节
1⃣️、组合式API & setup
https://vue3js.cn/docs/zh/guide/composition-api-introduction.html
https://www.cnblogs.com/catherLee/p/14487632.html
2⃣️、ref函数(响应式变量)
import { ref } from 'vue' //ref
对我们的值创建了一个响应式引用。使用引用的概念将在整个组合式 API 中经常使用。 const counter = ref(0) //ref
接受参数并返回它包装在具有value
property 的对象中,然后可以使用该 property 访问或更改响应式变量的值。 console.log(counter) // { value: 0 } console.log(counter.value) // 0 counter.value++ console.log(counter.value) // 1
3⃣️
编辑中.....