var windowHref = window.location.href;
if (windowHref.includes('/project/')) {
var splitURL = windowHref.split('/');
window.location.href = windowHref.substring(0, windowHref.indexOf('#/project')) + '?projectId=' + splitURL[splitURL.length - 2];
}
window.location.reload(true);
在执行上述代码之前
window.location.href
https://localhost:44301/default.aspx#/project/16a76abd-5b5b-4c63-822f-2bfd7f133adc/home
在执行之后,我希望它的价值是
https://localhost:44301/default.aspx?projectId=16a76abd-5b5b-4c63-822f-2bfd7f133adc
但是当线路
window.location.href = windowHref.substring(0,windowHref.indexOf('#/project')) + '?projectId=' + splitURL[splitURL.length - 2];
执行时
以及
windowHref.substring(0,windowHref.indexOf('#/project')) + '?projectId=' + splitURL[splitURL.length - 2];
https://localhost:44301/default.aspx?projectId=16a76abd-5b5b-4c63-822f-2bfd7f133adc