微信小程序兼容性

IOS常见兼容性

iOS中input的placeholder属性字体不居中
  • 对placeholder设置line-height及font-size
  • 对input设置高度
iOS中滚动卡顿
  • 设置-webkit-overflow-scrolling:touch
    1
    -webkit-overflow-scrolling: touch
iOS中new Date() 时间格式不兼容
  • 在实现倒计时,根据后台返回的时间格式转换时,后台返回了时间格式为”2018-11-12 11:12:11”,然后利用new Date() 转换时,ios中无法展示,安卓中显示正常
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    let time = '2018-12-10 11:11:11';
    let formateTIme = new Date(time);
    this.setData({
    formateTIme
    })
    /* 利用正则表达式替换时间中的”-”为”/”即可 */
    let time = '2018-12-10 11:11:11';
    let temporaryTime = new Date(time.replace(/-/g,'/'));
    let temporaryTime1 = new Date(time);
    this.setData({
    timeRemain: temporaryTime,
    timeRemain1: temporaryTime1,
    })
scroll-view隐藏滚动条方法
1
2
3
4
5
::-webkit-scrollbar{
width: 0;
height: 0;
color: transparent;
}
图片本地资源名称,尽量使用小写命名
  • 在解决iPhone X适配时,底部多余部分使用图片时

    1
    <image class='iphonexImg' src="/imgs/iphoneBGT.png" mode="aspectFill" />
  • 路径是 src=’imgs/iphoneBGT.png’(发现在pc IDE上面可以显示出来,但是真机调试时,图片找不到),将图片名称改为iphonex.png真机调试就可以了

    1
    <image class='iphonexImg' src="/imgs/iphonex.png" mode="aspectFill" />