Arrow function should not return assignment no-return-assign

Arrow function should not return assignment no-return-assign This is an eslint check error.

Explain the problems encountered when studying P221 of "The most complete and latest Vue and Vuejs tutorials in 2019, from entry to proficiency" on station B. Because the inspection code of eslint was quoted, the inspection error was reported. There is no problem with the code, it is the problem of eslint inspection.
Solution: 1. Remove eslint
2. Modify the code to conform to the
original eslint code

   if (this.isSelectAll) {
    
    
        this.cartList.forEach(item => item.checked = false)
      } else {
    
    
        this.cartList.forEach(item => item.checked = true)
      }

Changed code

   if (this.isSelectAll) {
    
    
        this.cartList.forEach(item => {
    
     item.checked = false })
      } else {
    
    
        this.cartList.forEach(item => {
    
     item.checked = true })
      }

After studying the arrow function, we can know that the {} added can be omitted, but the rules of eslint require it to be so.

Guess you like

Origin blog.csdn.net/qq_39088110/article/details/113562590