Vue calculation Properties

the following is a calculation property written, but if it is not shown in span, console.log can print

.

what went wrong

<span>{{areaUser}}</span>


  computed: {
    // 
    areaUser: function () {
      this.areaOptions.forEach( (element, index) => {
        if (element.id === this.temp.areaId) {
          console.log("")  
          return 11111111
        } 
      })
    }
  }
Apr.11,2021

The

clipboard.png
outer function must return a result.

areaUser: function () {
  let value = "";
  this.areaOptions.forEach( (element, index) => {
    if (element.id === this.temp.areaId) {
      console.log('')  
      value = 1111111; //
      return 11111111
    } 
  });
  return value;//computed
}

calculate the property needs a return value as the result of the calculation. You have return here, but the callback function return of forEach is not the calculation of the attribute return. You need to make the following modifications

areaUser: function () {
    var a;
    //forachsome
    this.areaOptions.some( (element, index) => {
        if (element.id === this.temp.areaId) {
            console.log('')  
            a = 11111111
            return true
        } 
    })
    return a
}

< hr > The return value of

computed is taken as the final result.
because when computed writes only one function, it is converted to a get function.

    computend: {
        foo() {
            return this.dataArray.map(v=>v.id)
        }
    }
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e26b-2c403.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e26b-2c403.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?