web-view 中嵌入H5页面,H5页面中有点击事件锚点滚动事件,在H5端跟小程序开发者工具里面调试正常定位滚动,
发布正式环境以后,在微信小程序端点击事件失效不滚动,在微信中打开H5地址访问,ios能正常点击事件滚动,在安卓中点击事件失效不滚动
有安卓跟ios兼容的问题
html:
<div>
<div onClick={() => navToMatch('itemId1')}>标签一</div>
<div onClick={() => navToMatch('itemId2')}>标签二</div>
</div>
<div id="itemId1">内容一</div>
<div id="itemId2">内容二</div>
js:
const navToMatch = (id: string) => {
try {
let dom = document!.getElementById(id) as any;
console.log(dom, dom.offsetTop, '高度', boxHeight);
let scroll = document!.getElementById(id)!.offsetTop - boxHeight;
// android ios 兼容api
if (isIos()) {
return (document.documentElement.scrollTop = scroll);
} else {
return (document.body.scrollTop = scroll);
}
} catch (err) {
console.log(err);
}
};