有什么方法可以在vuepress中更改vue路由器的模式

时间:2020-06-18 08:19:35

标签: vuepress

当前,vuepress中vue路由器的属性mode为“历史记录”

我想将vuepress中的vue路由器的属性mode更改为hash

有什么办法可以做到这一点?

我尝试在enhanceApp.js目录(https://vuepress.vuejs.org/guide/basic-config.html#app-level-enhancements)中创建像波纹管一样的文件.vuepress

export default ({
  Vue, // the version of Vue being used in the VuePress app
  options, // the options for the root Vue instance
  router, // the router instance for the app
  siteData, // site metadata
  isServer // is this enhancement applied in server-rendering or client
}) => {
  router.mode = 'hash';


}

但是没有运气。

1 个答案:

答案 0 :(得分:2)

// .vuepress\enhanceApp.js

import VueRouter from 'vue-router'

export default ({Vue, options, router, siteData
}) => {
  router = new VueRouter({
    ...router.options,
    mode: 'hash',
  })
}