computed 和vue2.x差不多,只是运用前要先引入。
watchEffect 监听
经过ref或许reactive去创立多个照应式的值,当任何一个值发作改动的时分,立刻触发这个函数。
watchEffect办法会前往一个stop handle中止监听。
router 路由
vue3.x的router和route属性也有了很大的变化,在vue2.x中运用this.$router路由跳转,this.$route获取以后页面路由信息。
// 路由跳转
import { useRouter} from "vue-router";
setup(){
const router=useRouter()
router.push('/path')
}
// 获取以后页面路由信息
import { useRoute} from "vue-router";
setup(){
const route=useRoute()
console.log(route) //这里的route相当于vue2.x中的this.$route
}
好了,就先剖析到这么多,后续也会陆续分享一些新变化。欢迎一同交流讨论!
(责任编辑:admin)