Vue-Router 路由属性解析

Vue2.0------Vue-Router 3.0


export default new Router({
    mode: 'history', //路由模式,取值为history与hash
    base: '/', //打包路径,默认为/,可以修改
    routes: [
    {
        path: string, //路径
        component: Component; //页面组件
        name: string; // 命名路由-路由名称
        components: ( ComponentName | ()=>import('页面地址') ); // 命名视图组件
        redirect: string | Location | Function; // 重定向
        props: boolean | string | Function; // 路由组件传递参数
        alias: string | Array<string>; // 路由别名
        children: Array<RouteConfig>; // 嵌套子路由
        beforeEnter?: (to: Route, from: Route, next: Function) => void; // 路由单独钩子
        meta: any; // 自定义标签属性,比如:是否需要登录
        icon: any; // 图标
        // 2.6.0+
        caseSensitive: boolean; // 匹配规则是否大小写敏感?(默认值:false)
        pathToRegexpOptions: Object; // 编译正则的选项
    }
]})

Vue3.0------Vue-Router 4.0

RouteRecordRaw=[
    path:string,//记录的路径。应该以 / 开头,除非该记录是另一条记录的子记录。可以定义参数:/users/:id 匹配 /users/1 以及 /users/posva。
    redirect:RouteLocationRaw | (to: RouteLocationNormalized) => RouteLocationRaw (可选), //重定向
    children:RouteRecordRaw 数组 (可选),//当前记录的嵌套路由。
    alias:string | string[] (可选)//路由的别名。允许定义类似记录副本的额外路由。这使得路由可以简写为像这种 /users/:id 和 /u/:id。 所有的 alias 和 path 值必须共享相同的参数。
    name:string | symbol (可选)//路由记录独一无二的名称。
    beforeEnter:NavigationGuard | NavigationGuard[] (可选)//在进入特定于此记录的守卫之前。注意如果记录有重定向属性,则 beforeEnter 无效。
    props:boolean | Record<string, any> | (to: RouteLocationNormalized) => Record<string, any> (可选)//允许将参数作为 props 传递给由 router-view 渲染的组件。当传递给一个多视图记录时,它应该是一个与组件具有相同键的对象,或者是一个应用于每个组件的布尔值。
    meta:RouteMeta (可选)//在记录上附加自定义数据。
]  
除非注明,文章均由开源 NetCore整理发布;
欢迎转载。转载请注明本文地址:https://www.netcore.pub/vue/333.html
站长会将优质文章在各大平台同步更新、推送,欢迎大家访问、订阅:
NetCore:NetCore
博客园:https://www.cnblogs.com/Zenderblogs/
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇