4***@qq.com
4***@qq.com
  • 发布:2021-07-23 17:52
  • 更新:2021-07-23 18:06
  • 阅读:1601

uniapp获取手机硬件设备信息,后台取不到

分类:uni-app

data() {
return {
platform: '',
mobileModel: '',
deviceId: '',
system: '',
windowWidth: ''

        }  

},
onLoad() {
uni.getSystemInfo({
success: function(res) {
// console.log(res.platform);
// console.log(res.model);
// console.log(res.system)
// console.log(res.windowWidth)
// console.log(res.deviceId)
var platform = res.platform
this.platform = platform //ios

                var mobileModel = res.model  
                this.mobileModel = mobileModel //iphone  

                var system = res.system  
                this.system = system  

                var deviceId = res.deviceId  
                this.deviceId = deviceId  

                var windowWidth = res.windowWidth  
                this.windowWidth = windowWidth  

            }  
        });  
    },  

发送给后台
this.$request.post('/register', {
deviceId: this.deviceId,
platform: this.platform,
mobileModel: this.mobileModel,
system: this.system,
windowWidth: this.windowWidth
}).then((regres) => {}
后台为空,前台可以打印,哪里写错了吗

2021-07-23 17:52 负责人:无 分享
已邀请:
风腾网络

风腾网络

延时300毫秒再上报,因为uni.getSystemInfo是异步的,目前情况是你上报时候,uni.getSystemInfo还没返回,所以空

该问题目前已经被锁定, 无法添加新回复