The newVal and oldVal returned by the watch array in vue are the same?

data() {
    return {
      colorlist: [
        {
          color: "-sharp333333",
          ftcolor: "-sharpffffff",
          name: "1"
        },
        {
          color: "-sharp55CD31",
          ftcolor: "-sharpffffff",
          name: "2"
        },
        {
          color: "-sharp31ADCD",
          ftcolor: "-sharpffffff",
          name: "3"
        }
      ]
    }
  },
  watch: {
    colorlist: {
      handler: function(val, oldVal) {
        console.log(val, oldVal)
      },
      deep: true
    }
  }

I changed the color of the third one to red. Console output result:

shouldn"t the color of the third oldVal be-sharp31ADCD?

Apr.11,2021

means something like this: when you print an array or an object, the value is taken by reference. When you change the array, the printed value naturally changes


.

look at document

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-1e4f779-45034.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-1e4f779-45034.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?