Home  >  Q&A  >  body text

javascript - The data component returned by axios request cannot be bound and rendered

The data I requested from the interface is assigned to the empty object wholedata defined in data. Writing a label loop on the page can traverse the data, but the data given to the component cannot be rendered. I added <li v-for='item in wholedata.materials.opt'></li>, the data will be output, but the error still exists. If you don't add this, the data will not be output. If you add v-if='wholedata', the data will not be output, because the initial output is a Empty object
Please ask for guidance! ! !

扔个三星炸死你扔个三星炸死你2663 days ago858

reply all(2)I'll reply

  • 世界只因有你

    世界只因有你2017-07-05 11:00:40

    Just modify the initial data format in data.

    data () {
      return {
        wholedata: {
          materials: {
            opt: []
          }
        }
      }
    }

    As long as the properties of the object are defined initially, Vue can detect data changes. You can also traverse the data directly in the form of v-for item in x.y.z.

    reply
    0
  • PHP中文网

    PHP中文网2017-07-05 11:00:40

    reply
    0
  • Cancelreply