1. 程式人生 > >微信小程式中的iOS相容性問題

微信小程式中的iOS相容性問題

記錄下在微信小程式中遇到的一些相容性問題,iOS相容性

1.iOS中input的placeholder屬性字型不居中

  • 對placeholder設定line-height及font-size
  • 對input設定高度

2.iOS中滾動卡頓

  • 設定-webkit-overflow-scrolling:touch;

3.微信小程式中解決iOS中new Date() 時間格式不相容

  • 在實現倒計時,根據後臺返回的時間格式轉換時,後臺返回了時間格式為”2018-11-12 11:12:11”,然後利用new Date() 轉換時,iOS中無法展示,安卓中顯示正常
let time = '2018-12-10 11:11:11';
let temporaryTime1 = new Date(time);
this.setData({
   timeRemain1: temporaryTime1,
})
/* 利用正則表示式替換時間中的”-”為”/”即可 */
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,
 })

4. 微信小程式scroll-view隱藏滾動條方法

  • 在wxss里加入以下程式碼:
::-webkit-scrollbar{
width: 0;
height: 0;
color: transparent;
}