2.判断pc端还是移动端的钉钉(此例子是Vue操作,React类似)
mounted: function() {
dd.device.base.getPhoneInfo({
onSuccess: function(data) {
/*
{
screenWidth: 1080, // 手机屏幕宽度
screenHeight: 1920, // 手机屏幕高度
brand:'Mi', // 手机品牌
model:'Note4', // 手机型号
version:'7.0', // 版本
netInfo:'wifi', // 网络类型 wifi/4g/3g
operatorType:'xx' // 运营商信息
}
*/
// alert(JSON.stringify(data));
alert('现在是手机移动端');
},
onFail: function(err) {
alert(JSON.stringify(err));
}
});
//PC端钉钉执行此方法
if (DingTalkPC.ua.isDesktop && DingTalkPC.ua.isInDingTalk) {
alert("你在用电脑看?");
}
}
本文的解决方案灵感来自https://blog.csdn.net/qq_29819449/article/details/80328181