c***@qq.com
c***@qq.com
  • 发布:2019-05-26 11:15
  • 更新:2020-03-25 14:36
  • 阅读:5138

uniapp 做的小程序,发布之后,出现一个问题,第一次加载数据空白,下拉后正常!

分类:uni-app

uniapp 做的小程序,发布之后,第一次加载页面空白,下拉刷新后正常,可是在本地和微信开发工具上都没问题!

this.GetNewsList(); //动态获取数据
//setTimeout模拟异步请求数据
setTimeout(() => {
//list = json.newsList;

                if (type === 'refresh') {  
                    console.log('刷新');  
                    tabItem.newsList = []; //刷新前清空数组  

                }  
                list.forEach(item => {  
                    //item.id = parseInt(Math.random() * 10000);  
                    tabItem.newsList.push(item);  
                    //console.log(tabItem.loadMoreStatus);  
                })  
                //下拉刷新 关闭刷新动画  
                if (type === 'refresh') {  
                    this.$refs.mixPulldownRefresh && this.$refs.mixPulldownRefresh.endPulldownRefresh();  
                    // #ifdef APP-PLUS  
                    tabItem.refreshing = false;  
                    // #endif  
                    tabItem.loadMoreStatus = 0;  
                }  
                //上滑加载 处理状态  
                if (type === 'add') {  
                    tabItem.loadMoreStatus = tabItem.newsList.length > 40 ? 2 : 0;  
                }  
            }, 600)
2019-05-26 11:15 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com - 刘灿成

我也遇到这问题,什么原因啊?

6***@qq.com

6***@qq.com

你们解决了吗?怎么解决的

  • c***@qq.com (作者)

    算是解决了吧!

    uni.showLoading({

    title: '加载中'

    });

    axios.post('').then(

    (res) => {

    this.$nextTick(() => {

    list = res.data;

    console.log(list);

    this.showCard=true;

    })


                        setTimeout(function() {  
    uni.hideLoading();
    }, 2000);
    });

    用了一个这个东西:this.$nextTick

    2020-03-26 14:21

  • 6***@qq.com

    回复 c***@qq.com: 感谢,我马上试试

    2020-03-26 22:50

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