数据需要刷新后显示(Vue)

问题描述

我的页面数据出现了需要刷新后才能更新数据,或者需要往复几次才能渲染上去

解决方法

解决方法其实很简单,就是因为你没有清空数据

方法一:直接清空data域

this.judgeData = []

方法二:再次调用接口(数据来自接口)

在这里,我的数据来自getDetail

而且无法直接使用方法一

		this.getDetail()
		// 每次在开始就调用,用接口数据重置
        var time = setInterval(() => {
          this.checkIndex++
          this.getDetail()

          curTable[index].topicStatus = this.dataDetail.data.topic_status
          if (this.dataDetail.data.topic_status !== '正在测试') {
            this.checkIndex = 0
            clearInterval(time)
          }

          if (this.checkIndex >= 10) {
            this.checkIndex = 0
            clearInterval(time)
            this.$message({
              type: 'error',
              message: '服务器出错,请稍后重试!',
            })
            curTable[index].topicStatus = '测试失败'
          }
        }, 1000)

版权声明:本文为qq_22841387原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。