路由 vue-router

vue-router官方文档html

1.router跳转页面

编程式的导航vue

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

2.mode

Router构造配置vue-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,路由会自动强制进入这个模式。
相关文章
相关标签/搜索