Calculating data using computed in vue does not take effect.

relies on props"s data data in the calculation attribute. When data is updated, computed does not fetch data data in real time. (originally intended to change through watch data, but watch has not been executed, but the data data itself has changed, which is very strange.) the
code is as follows:

    props: {
        data: {
            default: () => {},
            type: Object,
        },
    },
    data() {
        return {
        };
    },
    created() {
    },
    computed: {
        ...mapState({
        }),
        handleTotalPrice() {
            return this.fixNumber(this.totalPrice);
        },
        handledData() {
            const handledData = JSON.parse(JSON.stringify(this.data)); // 
            Object.entries(handledData).forEach(([key, value]) => {
                if (value.price) {
                    handledData[key].price = this.fixNumber(value.price);
                }
                if (value.list) {
                    ...
                }
            });
            return handledData;
        },
    },
watch: {
    // 
    data(newV, oldV) {
        console.log("submit watch");
    },
    data: {
        handler(newV, oldV) {
            console.log("submit watch");
        },
        deep: true,
        
    },
},
< hr >

has located the problem. Setting the value of obj in the parent component requires methods such as set or splice, otherwise the child component cannot listen.
thought that only the domestic demand of this component had to pass set, but I never thought.

Apr.29,2022

there is one thing to note when using listening. When a component is first loaded, it passes in props, which is not triggered in my impression.


both have been tested, and both are triggered

<template>
    <div>
        <div>{{total}}</div>
        <div>{{totalTest}}</div>
    </div>
</template>
<script>
export default {
  props: {
    data: String
  },
  components: {},
  data () {
    return {
    }
  },
  computed: {
    total () {
      return this.data + ''
    },
    totalTest () {
      const handledData = JSON.parse(JSON.stringify(this.data)) // 
      return handledData + ''
    }
  },
  watch: {
    data (newV, oldV) {
      console.log(11111)
    }
  },
  created () {
  },
  methods: {}
}
</script>

clipboard.png

clipboard.png

object, also triggered

<template>
  <div>
    <div>{{total.number}}</div>
    <div></div>
  </div>
</template>
<script>
export default {
  props: {
    data: {
      type: Object
    }
  },
  components: {},
  data () {
    return {

    }
  },
  computed: {
    total () {
      const handledData = JSON.parse(JSON.stringify(this.data)) // 
      handledData.number = handledData.number + 'hhhhh'
      return handledData
    }
  },
  created () {
  },
  methods: {}
}
</script>

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