小さなプログラムで開発者ツールかAndroid、iosかを判断する方法

序文:

        開発者ツールなのか Android なのか ios なのかを小さなプログラムで判断する方法は、コードによっては特殊な環境で処理する必要があるため、ここで共有します。

公式の方法:

        wx.getSystemInfo と wx.getSystemInfoSync はどちらもシステム情報を取得しますが、非同期と同期の違いwx.getSystemInfo(Object object) | WeChat オープン ドキュメントWeChat 開発者プラットフォーム ドキュメントhttps://developers.weixin.qq.com/minigame/dev/ API/ベース/システム/wx.getSystemInfo.html

アプレットで開発者ツールかそれ以外か判断するには?

// 开发者工具
const platform = wx.getSystemInfoSync().platform

//开发者工具
if(platform === "devtools"){}

//ios  包含 iPhone、iPad
if(platform === "ios"){}

//安卓
if(platform === "android"){}

API:

アプレットは携帯電話の幅や高さなどの情報をどのように取得しますか?

wx.getSystemInfoSync().windowWidth;	//获取设备屏幕宽度

wx.getSystemInfoSync().windowWidth;	//获取设备屏幕宽度

API:

 

おすすめ

転載: blog.csdn.net/qq_41619796/article/details/129731000