Is there a question about the immediate option for vue watch listeners? O_0?!!

The code in

watch is very simple. A request takes data
sets the immediate to enter the page and executes

watch:{
        post:{
            handler(newValue,oldValue){
                P.FilterData({"type":this.post.project})
                .then((res)=>{
                    this.FilterData = res.data
                })
            },
            immediate: true,
            deep:true,
        },
    },

this is what the data looks like.




Why can"t I get the transfer here?
is the rendering performed before getting the data?
where should I change?

May.05,2022

you should be calling something asynchronous. Until the operation is completed, you can't get the result


it should be too early for dom operation. Try this.
add a v-if

<template>
  <div class="select">
    <span><i style="color:red">*</i></span>
    <Select v-model="post.transfers" style="width:300px" v-if="dataLoaded">
      <Option v-for="item in FilterData.transfers" :value="item.name">{{ item.name }}</Option>
    </Select>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      dataLoaded: false
    };
  },
  watch: {
    post: {
      handler(newValue, oldValue) {
        P.FilterData({ type: this.post.project }).then(res => {
          this.dataLoaded = true;
          this.FilterData = res.data;
        });
      },
      immediate: true,
      deep: true
    }
  }
};
</script>

if you have any more questions, contact me in time

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