怎么判断当前是否在pc端的小程序当中 , 因为项目是SSR的项目,所以之前是通过其他以依赖来判断UA来区分的 但是这pc端的小程序 区分不出来 ,但是这个时候也访问不到window 该怎么解决!!!
const checkMobile = (that) => {
// console.log('--------that.$ua---', that.$ua);
const deviceType = that.$ua.deviceType();
let ua = that.$ua._ua.toLowerCase()
if (deviceType === "smartphone" || deviceType === "mobilephone" || (ua.indexOf("MicroMessenger") !== -1 && that.$el.clientWidth < 767)) {
return true;
} else if (deviceType === "crawler") {
return that.$ua._ua.toLowerCase().includes("mobile");
} else {
return false;
}
};
判断在哪个端,再对webview
进行赋值,https://developers.weixin.qq.com/miniprogram/dev/api/base/system/wx.getSystemInfoAsync.html