ancientry
ancientry
  • 发布:2026-07-21 08:53
  • 更新:2026-07-21 08:53
  • 阅读:54

#提交BUG# 腾讯地图在h5下面uni.getLocation uni.chooseLocation失败-已解决

分类:uni-app

腾讯地图在h5下面 uni.getLocation uni.chooseLocation失败,经过几天发现是Referer为空;系欸版办法如下,请官方级市修复。

解决代码如下:
onLoad: function() {
// ===== H5 端:强制所有 script 标签发送 Referer(修复 uni.chooseLocation 空白)=====
// #ifdef H5
if (!window.scriptReferrerFixed) {
window.
scriptReferrerFixed = true;
var originalCreateElement = document.createElement;
document.createElement = function(tagName) {
var el = originalCreateElement.call(document, tagName);
if (tagName.toLowerCase() === 'script') {
el.referrerPolicy = 'origin';
}
return el;
};
}
// #endif

uni.showLoading({ title: '加载中...' });  

// ... 你原来的 onLoad 代码 ...  

}

2026-07-21 08:53 负责人:无 分享
已邀请:

要回复问题请先登录注册