嘟嘟灬鳕
嘟嘟灬鳕
  • 发布:2020-06-11 09:14
  • 更新:2020-06-15 09:22
  • 阅读:982

【报Bug】onload执行request请求加载不了数据

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 2.7.9.20200527

HBuilderX类型: 正式

HBuilderX版本号: 2.7.9

手机系统: Android

手机系统版本号: Android 9.0

手机厂商: 小米

手机机型: MI PAD 4PLUS

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

onLoad() {
this.Show_homebar();
// 获取屏幕宽度
windowWidth = uni.getSystemInfoSync().windowWidth;
uni.setStorage({
key: 'khbm',
data: this.khbm,
success() {}
}),
uni.setStorage({
key: 'khmc',
data: this.khmc,
success() {}
}),
uni.getStorage({
key: 'user_id',
success: e => {
this.user_id = e.data;
}
}),
uni.getStorage({
key: 'shop',
success: e => {
this.ksbm = e.data;
}
}),
uni.getStorage({
key: 'khmcjs',
success: e => {
this.khmcjs = e.data;
}
}),
uni.getStorage({
key: 'date',
success: e => {
this.date_one = e.data;
}
}),
this.Show_tzt();
uni.hideTabBar();
// #ifdef APP-PLUS
this.statusHeight = plus.navigator.getStatusbarHeight();
// #endif
this.amapPlugin = new amap.AMapWX({
//高德地图KEY,随时失效,请务必替换为自己的KEY,参考:http://ask.dcloud.net.cn/article/35070
key: 'fedf7809f280da0d019452aebb9289ec'
});
//定位地址
this.amapPlugin.getRegeo({
success: data => {
this.city = data[0].regeocodeData.addressComponent.city.replace(/市/g, ''); //把"市"去掉
}
});

    //开启定时器  
    this.Timer();  
    //加载活动专区  
    this.loadPromotion();  
    this.loadTabbars();  
    this.Get_user();  
    //this.Get_xptj();  
}

操作步骤:

在onload写request方法

预期结果:

onload中执行request的方法可以加载出数据

实际结果:

onload中执行request的方法不能加载出数据,需要写在mounted

bug描述:

发现最新版本生成的程序,onload中通过函数方法执行request,不能获取数据。
也就是页面加载完成后我不能正常加载出网络数据,需要将方法写在mount中或者切换一下页面才能出来。
在以前的hbuilder中是可以正常使用

2020-06-11 09:14 负责人:无 分享
已邀请:
希

试试加个延时呗,可能页面渲染比数据快,或者在获取数据赋值后面加个强制渲染(猜的,嘿嘿)

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