0

メイン ドメインと/the/rest/of/url.

どうやら、私はそれを正しくしていません。

私が使用した:

 window.location.hash = location.pathname;

との交換http://www.mybusinesssite.com/path/to/mypageを希望http://www.mybusinesssite.com/#/path/to/mypage

代わりに、私は得るhttp://www.mybusinessite.com/path/to/mypage/#/path/to/my/page

正しい作り方とはhttp://www.mybusinesssite.com/#/path/to/mypage ?

4

3 に答える 3

3

試す

window.location = location.protocol + '//' + location.host + '/#' + location.pathname

表示される URL を変更したい場合は、プッシュ状態を使用できます。

history.pushState({}, "page x",  location.protocol + '//' + location.host + '/#' + location.pathname);

https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Manipulating_the_browser_historyを参照してください

于 2013-06-03T17:05:01.263 に答える