Vue Router参数大全
发布日期:2021-10-09 15:34:57 浏览次数:1 分类:技术文章

本文共 1206 字,大约阅读时间需要 4 分钟。

Vue Router对象创建

在这里插入图片描述

Vue Router构建选项详解

参数 类型 默认值 可选值 描述
routes Array 配置路由规则
mode string “hash” (浏览器环境) /“abstract” (Node.js 环境) “hash”/“history” / “abstract” 配置路由模式
base string / 应用的基路径
linkActiveClass string router-link-exact-active 全局配置 默认的精确激活的 class
scrollBehavior Function 配置滚动行为
parseQuery / stringifyQuery Function 提供自定义查询字符串的解析/反解析函数
fallback boolean 当浏览器不支持 history.pushState 控制路由是否应该回退到 hash 模式。默认值为 true

Vue RouteConfig 的类型定义

export interface RouteConfig {  path: string;  name?: string;  component?: Component;  components?: Dictionary
; redirect?: RedirectOption; alias?: string | string[]; children?: RouteConfig[]; meta?: any; beforeEnter?: NavigationGuard; props?: boolean | Object | RoutePropsFunction; caseSensitive?: boolean; pathToRegexpOptions?: PathToRegexpOptions;}
属性 详解
path 路径
name 命名路由
component 命名视图组件
components 命名视图组件
redirect 重定向路径
alias 别名
children 嵌套路由
meta 路由元信息 使用$route.meta.属性可以获取
caseSensitive 匹配规则是否大小写敏感?(默认值:false)
pathToRegexpOptions 编译正则的选项

Vue Router Mode详解

hash: 使用 URL hash 值来作路由。支持所有浏览器,包括不支持 HTML5 History Api 的浏览器。history: 依赖 HTML5 History API 和服务器配置。查看 HTML5 History 模式。abstract: 支持所有 JavaScript 运行环境,如 Node.js 服务器端。如果发现没有浏览器的 API,路由会自动强制进入这个模式。

转载地址:https://blog.csdn.net/qinwuxian19891211/article/details/105900083 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:一文了解vue基本概念
下一篇:npm常用命令汇总

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年04月15日 14时38分50秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章