current position:Home>[taro react] - H5 route configuration cancels # on the route

[taro react] - H5 route configuration cancels # on the route

2022-04-29 09:35:30Rattenking

Default package access route

https://{ {domain}}/#/pages/index/index

Expect packaged access routes

https://{ {domain}}/pages/index/index

Solution document

taro Routing related configuration h5.router

Configure routing mode

Configure routing mode .‘hash’ And ‘browser’ They correspond to each other hash Routing mode and browser history Routing mode . The default value is :‘hash’.

example

Modification item config/index.js

module.exports = {
  // ...
  h5: {
    // ...
    router: {
      mode: 'browser' //  Or is it  'hash'
    }
  }
}

For the above configuration , call Taro.navigateTo({ url: ‘/pages/index/index’ }) after , The browser address bar will be changed to :

  1. https://{ {domain}}/#/pages/index/index(hash Pattern )
  2. https://{ {domain}}/pages/index/index(browser Pattern )

copyright notice
author[Rattenking],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204290807048901.html

Random recommended