docs icon indicating copy to clipboard operation
docs copied to clipboard

Wrong description of custom directive in documentation(vue 3)

Open rinbowLi opened this issue 4 years ago • 1 comments

image This is the description in the documentation(vue3) the link to the documentation

  • test code
<script>
import { ref, onMounted,onBeforeMount } from "vue";
export default {
  directives: {
    focus: {
      beforeMount() {
        console.log("custom-directive's beforeMount");
      },
      mounted(el) {
        console.log("custom-directive's mounted");
        el.focus();
      },
    },
  },
  setup() {
    const inputValue = ref("123");


    onBeforeMount(() => {
      console.log("component's onBeforeMount");
    });

    onMounted(() => {
      console.log("component's onMounted");
    });


    return () => (
      <div>
        <h2>{inputValue.value}</h2>
        <input v-model={inputValue.value} v-focus />
      </div>
    );
  },
};
</script>

image

Here is a screenshot of the printout

Obviously the mounted of the custom directive is earlier than the onMounted of the component, so the documentation describes the error

rinbowLi avatar Jan 12 '22 01:01 rinbowLi

Closing the issue as related PR was merged

NataliaTepluhina avatar Jan 12 '22 18:01 NataliaTepluhina