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) => {}
后台为空,前台可以打印,哪里写错了吗
1 个回复
风腾网络
延时300毫秒再上报,因为uni.getSystemInfo是异步的,目前情况是你上报时候,uni.getSystemInfo还没返回,所以空