我有一个包含道具和数据的组件。 组件接收新的道具,我看到道具,我影响数据上的新道具,但......没有渲染我的组件
来源:
<template>
<div> <label :dataField="(userSelected.email) ? userSelected.email :null" </label>
</template>
export default {
props: {
user: {
type: Object,
required: true,
default: null
},
data() {
return {
userSelected: this.$props.user,
}
},
watch: {
user(newProps){
console.log(" DATA = ", JSON.stringify(newProps))
console.log(" DATA = ", JSON.stringify(this.userSelected))
if ( JSON.stringify(newProps) !== JSON.stringify(this.userSelected) ) {
console.log("different props ")
this.userSelected = null;
this.userSelected = JSON.parse(JSON.stringify(newProps));
// the component is update but he doesn't render the html
}
}
},
}