Skip to content

Latest commit

 

History

History
50 lines (36 loc) · 1.23 KB

H5开发问题汇总及解决方案.md

File metadata and controls

50 lines (36 loc) · 1.23 KB

问题:DOM元素固定一边,另一边滚动,滚动很卡的问题

解决方案:

-webkit-overflow-scrolling: touch;

问题:部分手机第三方输入法会将页面网上挤的问题

解决方案:

// 特定需求页面,比如评论页面,输入框在顶部之类的
const interval = setInterval(function() {
    document.body.scrollTop = 0;
}, 100)
// 注意关闭页面或者销毁组件的时候记得清空定时器
clearInterval(interval);

问题:iPhoneX适配

解决方案:

// 1.viewport meta 标签增加属性viewport-fit=cover
<meta name="viewport" content="width=device-width, viewport-fit=cover, ...other">
// 2.body元素增加样式
body {
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
}
// 3.如有fixed底部的元素,也增加上面样式
.fixed {
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
  background-color: #fff; // 记得添加background-color,不然会出现透明镂空的情况
}

问题:ios 日期转换NAN的问题

解决方案:

将日期字符串的格式符号替换成'/'。 栗子:'yyyy-MM-dd'.replace(/-/g, '/')