if(navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger'){WeixinJSBridge.call('closeWindow')}else{if(navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Linux') > -1){window.opener=null;window.open('about:blank','_self','').close();}else {window.opener = null;window.open("about:blank", "_self");window.close();}}
//input失去焦点时调用以下代码,解决ios键盘收起时不恢复位置
setTimeout(() => {const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;window.scrollTo(0, Math.max(scrollHeight - 1, 0));}, 100);
//监听键盘回车键,收起键盘
document.οnkeydοwn=function(e){ //对整个页面文档监听var keyNum=window.event ? e.keyCode :e.which; //获取被按下的键值
//判断如果用户按下了回车键(keycody=13)
if(keyNum==13){e.preventDefault();document.activeElement.blur(); // 关闭软键盘}}
//有些情况下进入一个页面调用scrollTop事件不生效,原因可能是采用了动画,采用异步操作即可解决
setTimeout(() => {let height=document.getElementsByClassName('ul-scoll')[0].getElementsByTagName('li')[0].clientHeight;document.getElementsByClassName('ul-scoll')[0].scrollTop=(index-2)*height},0)
//解决蒙层点透问题
document.getElementsByTagName('body')[0].style.overflow='hidden'; //show时 document.getElementsByTagName('body')[0].style.overflow='auto';//hide时
this.list.ssId=res.data.list.ssId+'';
仅做个人项目记录,如有错误,请指教!