The vue props is passed to the subcomponent and does not get a value.

parent component

 <index-map map-name="index-map" :pro-data="mapArr" :maker-data="listData" :marker-id.sync="markerId" :apply-flag.sync="statusModal" @marker-tap="markerTap"></index-map>

data () {

mapArr:[],

}

proChange(params){
  let mapArr;
  this.prolistData.forEach((item, i) => {
    if (item.areaid == this.params.proid) {
      mapArr = item;
    }
  });
  console.log("mapArr",mapArr);
},

subcomponents

props: ["makerData", "markerId", "mapName","proData", "applyFlag"],
watch: {
  proData: function(val, oldVal) {
    console.log("====41",val);
    if (val) { 
      this.mapPosition(this.proData);
    }
  },
},
 mapPosition(mapArr) {
    console.log(mapArr);
     this.map.centerAndZoom(new T.LngLat(mapArr.longitude, mapArr.latitude), mapArr.zoom);
  },

mapPosition I change the value of mapArr in the parent component the child component mapPosition does not execute

Nov.14,2021

the parent component did not change the myAttr, you re-let declared one.
and because you assign values directly to the parent component, the array object in the child component is still the original object, but the parent component has nothing to do with the original array object due to re-assignment.


add a new variable to the subcomponent

data(){
proDataNew:''
},
mounted(){
proDataNew = this. proData
},
watch:{
proDataNew(){
    //todo
}
}
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-1b3eb08-2c417.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-1b3eb08-2c417.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?