js 谷歌浏览器数组里面有个对象 展开之前对象里的顺序是对的 展开后数据顺序就错了的处理方法

getList() {
      this.loading = true;
      let params = {
        title: this.form.title,
        account_id: this.form.account_id,
        status: this.form.status,
        page: this.form.page,
        page_size: this.form.page_size,
      }
      biliReportColumnHourlyNoticePageConfig(params).then((res) => {
        this.total = res.data.data.total;
        this.tableList = res.data.data.records.map(item => {
          let ofields = Object.entries(JSON.parse(JSON.stringify(item.fields))).map(item => ({
            id: "",  // 你可以根据需求为 id 赋值
            keyName: item[0],
            title: item[1]
          }))
          item.status = item.status == 1;  // 如果是 1,设置为 true;否则,设置为 false
          item.fields = ofields //直接获取的话 顺序会有问题
          return item;
        });       
        this.loading = false;
      });
    },

Object.entries(JSON.parse(JSON.stringify(item.fields))) 使用该方法把对象变成数组

我发现JSON.stringify(item.fields)这个状态下的顺序是对的

你可能感兴趣的:(js,javascript,前端,开发语言)