VUE 3.0
setup()函数替换了created和beforCreat
data被出名
声明动态绑定的变量要使用ref和reactive
ref用来声明基本类型如String Number
reactive用来声明复杂类型如 Array Object
router 和 route
使用router要引入 useRouter
import { useRouter, useRoute } from 'vue-router
let router = useRouter()
let route = useRoute()
使用router
router.push()
router.back()
router.go()
...
使用route
route.params
route.query
使用vuex
import { useStore } from 'vue-router
let store = useStore()
store.commit('xx')
store.dispatch('xxx')
...
生命周期大更新
beforeMount -> onBeforeMount
mounted -> onMounted
beforeUpdate -> onBeforeUpdate
updated -> onUpdated
beforeDestroy -> onBeforeUnmount
destroyed -> onUnmounted
errorCaptured -> onErrorCaptured
之前方法
例如nextTick现在也需要先引入在使用生命周期也需要先引入
import { nextTick, onBeforeMount ... } from 'vue'