In Vue, an error may be reported when assigning the array acquired in the background to the object

dialogTableCilck1(row) {
      const data = {
        forderNo: row.orderNo
      }
      console.log(data)
      this.$post('', data).then(request => {
        console.log(request)
        this.dialogData1 = request
        if (this.dialogData1.length > 0) {
          this.receivable = this.dialogData1[0]
        }
      })
    },

After sending a request to the background, get an array type of data, and then assign the data with index 0 in the array to an object. When the page is initialized or reloaded, there is no value in the array, so the index cannot be found. The value of 0 will report an error when assigning it to an object, so when assigning the value under the array index to an object, a judgment must be made, otherwise an error will be reported 

Guess you like

Origin blog.csdn.net/kobe_IT/article/details/130222182