当在ios中直接食用 location.replace 替代路径是完全可以的,但在安卓中却起不到替代的作用而变成了跳转,那么考虑到兼容性问题使用以下兼容:
function replace() {
if (history.replaceState) { // 安卓兼容
history.replaceState({}, document.title, url);
location.reload(); //刷新
} else {
location.replace(url); // ios
}
}