嗨,我有 ui-router 的问题。我的网址已被替换,但页面未重新加载。 我使用“@uirouter/angularjs”:“^1.0.26”,“Angular”:“~1.5.11”,
我的代码在我的 $stateProvider 解析中
$transitions.onSuccess({}, function (transition) {
options.forEach((options) => {
api
.load()
.then((response) => {
if (response) {
const currentUrl = $location.absUrl();
let updatedUrl = currentUrl;
response.data.forEach((element) => {
if (element) {
const regex = new RegExp(`'${element}~`);
if (updatedUrl.match(regex)) {
updatedUrl = updatedUrl.replaceAll(
`'${element.data}~`,
`'${element.data.plam}~`
);
}
}
});
if (updatedUrl !== currentUrl) {
$timeout(function() {
$window.location.href = updatedUrl;
});
}
}
});
});
});
我使用两者解决了我的问题
$window.location.href = updatedUrl;
和
$window.location.reload();