Vue parent component tune child component method, status updated, but not applied

//
<template>
  <section v-show="bool">11</section>
</template>
<script>
export default {
  data() {
    return {
      bool: false
    };
  },
  mounted() {
  },
  methods: {
    aaa() {
      let that = this;
      that.bool = true;
      console.log(that.bool);
      setTimeout(() => {
        that.bool = false;
        console.log(that.bool);
      }, 2000);
    }
  }
};
</script>
< hr >
//
<template>
  <section>
      <zujian></zujian>
  </section>
</template>
<script>
import zujian from "@/components/zujian";
export default {
  data() {
  },
  mounted() {
    zujian.methods.aaa();
  },
  components: {
    zujian
  }
};
</script>

after the parent component is called, the console of the child component is correct twice, but the state of the child component does not change.

Mar.04,2021

the parent component can control the child component, but the child component cannot control the parameters of the parent component. If you want to turn off the display, write the method callback on your child component and change the state


in your parent component.

self-question and answer
tune

in the form of refs
//
<template>
  <section>
      <zujian ref="zujian"></zujian>
  </section>
</template>
<script>
import zujian from "@/components/zujian";
export default {
  data() {
  },
  mounted() {
    this.$refs.zujian.aaa();
  },
  components: {
    zujian
  }
};
</script>

this.$children [0] .AAA ();

Menu