本文共 605 字,大约阅读时间需要 2 分钟。
通过多次尝试,发现直接使用JavaScript控制页面重定向存在一定的挑战性。以下是实现成功的具体方法和优化建议:
var newWin = window.open('https://www.baidu.com/');wxPublic().then(function() { if (res.data.statusCode !== '200') { newWin.location.href = '404页面'; return; } newWin.location.href = res.data.responseContent.url;}).catch(function() { newWin.location.href = '404页面'; // 可以选择关闭新窗口:newWin.close();}); window.open('loading.html'); 通过以上方法,可以有效提升页面加载速度,确保用户体验不受影响。
转载地址:http://pcptz.baihongyu.com/