vue3.0中的路由及路由守卫

1.vue3.0与vue2.0路由的变化

  tag是我们可以改变标签的属性进行了删除,event也删除了、exact也进行了删除

  全局的404不再使用*键了,文档有可查看

  有一个新增的API就是v-slot,具体怎么使用,需要稍等会,正在努力研究中

  还有我们的组件路由守卫中的beforeRouteEnter进行了删除

  新增的两个API是我们经常会使用到的,很有用useRouter,useRoute后面会介绍到,别慌

2.Vue3.0简单语法样例

import { createRouter, createWebHashHistory } from "vue-router"

const routes = [
        {
            name: 'login',
            path: "/login",
            component: () => import('./page/login-page/index'),
        },
        {
            name: 'home',
            path: "/",
            component: () => import('./page/home-page/index'),
        }
    ]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

export default router;

 

参考文章:

  链接:https://www.jianshu.com/p/9f527389e6cf

posted @ 2022-01-14 10:32  㭌(mou)七  阅读(422)  评论(0)    收藏  举报