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.