解决报错:Uncaught (in promise) TypeError: _this.roomInformation.push is not a function

 当点击归档时,打印台出现这个报错,但是对页面没有影响。

//接口中的代码直接处理,并赋值给页面需要用的字段——————原本方法,导致报错

response.data.roomList.forEach(item => {
            this.roomInformation.push(item.building + '-' + item.floor + '-' + item.room)
          })
          this.roomInformation = this.roomInformation.join(',')



//将获取的接口数据用data定义的数据接住,并新增一个数据存储处理的数据。最后再处理赋值给需要显示的页面使用————修改后的方法,页面没有报错

const roomList = []
          this.contractData.roomList.forEach(item => {
            roomList.push(item.building + '-' + item.floor + '-' + item.room)
          })
          this.roomInformation = roomList.join(',')

猜你喜欢

转载自blog.csdn.net/m0_65274248/article/details/128058591
今日推荐