url参数中文带下划线‘_’,导致浏览器挂起,报错:
Throttling navigation to prevent the browser from hanging. See https://crbug.com/1038223. Command line switch --disable-ipc-flooding-protection can be used to bypass the protection
原因是浏览器参数中,中文带下划线
127.0.0.1:8080?name=项目名_测试1
这种情况会导出浏览器报错,页面无法访问。
原因如下:
浏览器显示“Throttling navigation to prevent the browser from hanging.”这样的信息,通常是因为浏览器检测到短时间内有大量的页面跳转或请求,认为这可能是恶意行为或可能导致浏览器崩溃,因此进行了限制。这是Chrome浏览器的一项安全特性,用以防止IPC(Inter-Process Communication)洪水攻击。
解决:
URL编码:对URL中的中文参数进行编码。在JavaScript中,你可以使用encodeURIComponent函数来编码URL参数。这样,中文字符会被转换为有效的URL编码形式,可能会解决浏览器挂起的问题。
const query = {
projectName: encodeURIComponent(this.projectInfo.name),
}
this.$router.replace({
name: 'ExpertProgress',
query: Object.assign({}, query),
})