1、需要借助的API:wx.getSystemInfoSync();
通过API可获取的值:
// 在 iPhone6 下运行:var systemInfo = wx.getSystemInfoSync();console.log(systemInfo.windowWidth); // 输出 375(单位 px) // 在 iPhone6 Plus 下:var systemInfo = wx.getSystemInfoSync();console.log(systemInfo.windowWidth); // 输出 414 (单位 px)
2、px与rpx之间转换的公式:px = rpx / 750 * wx.getSystemInfoSync().windowWidth;
动画中如何使用:
//假设我想向右平移300rpx,动画代码如下:this.animation.translateX(300 / 750 * systemInfo.windowWidth).step()
这样在所有机型上都可以进行适配。
作者:Brighten_Sun
链接:https://www.jianshu.com/p/256f8ba0a7aa
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦