路由 vue-router

vue-router官方文档

1.router跳转页面

编程式的导航

this.$router.push('/index');

2.mode

Router构造配置

const router = new VueRouter({
    mode: 'history',
    mode: 'hash', //布置服务器后刷新能找到页面
    routes: routes 
})

mode
类型: string

  • 默认值: "hash" (浏览器环境) | "abstract" (Node.js 环境)
  • 可选值: "hash" | "history" | "abstract"
    配置路由模式:
  • hash : 使用 URL hash 值来作路由。支持所有浏览器,包括不支持 HTML5 History Api 的浏览器。
  • history: 依赖 HTML5 History API 和服务器配置。查看 HTML5 History 模式.
  • abstract : 支持所有 JavaScript 运行环境,如 Node.js 服务器端。如果发现没有浏览器的 API,路由会自动强制进入这个模式。
原文地址:https://www.cnblogs.com/jehorn/p/7744037.html