docs
docs copied to clipboard
Wrong description of custom directive in documentation(vue 3)
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>

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
Closing the issue as related PR was merged