是否可以在#{1}}到/#/
的哈希模式中编辑主题标签的位置?
不支持/#
时(在较旧的浏览器中html5mode
及以下),我获得IE9
hash URL
/
模式
我得到了什么:
hashbang
我想得到什么:
'index.com/#/path/id'
是否可以在角度应用配置中修改'index.com/path/#id'
的网址/展示位置?或者我想要一个未接受/无效的哈希模式URL?
答案 0 :(得分:0)
在路由器页面中添加此代码
$locationProvider.html5Mode(true);
答案 1 :(得分:0)
您无法在不支持#
API的浏览器中从网址中删除history
。
mode=true
中html5Mode
时
已启用 -
{boolean}
- (default: false
)如果为true,将依赖history.pushState
更改支持的网址。将回归 不支持hash-prefixed
的浏览器中的pushState
个路径。
From $locationProvider
source code,如果history.pushState
失败,则会恢复旧的网址值:
function setBrowserUrlWithFallback(url, replace, state) {
var oldUrl = $location.url();
var oldState = $location.$$state;
try {
$browser.url(url, replace, state);
// Make sure $location.state() returns referentially identical (not just deeply equal)
// state object; this makes possible quick checking if the state changed in the digest
// loop. Checking deep equality would be too expensive.
$location.$$state = $browser.state();
} catch (e) {
// Restore old values if pushState fails
$location.url(oldUrl);
$location.$$state = oldState;
throw e;
}
}