How to get the name
of a component or routing page in the outer layer?
#11683
Answered
by
Shyam-Chen
warmthsea
asked this question in
Help/Questions
-
Beta Was this translation helpful? Give feedback.
Answered by
Shyam-Chen
Aug 22, 2024
Replies: 1 comment 5 replies
-
<script lang="ts" setup>
import { ref } from 'vue';
import Comp from './Comp.vue';
const target = ref();
function getCompName() {
console.log(target.value.$options.name);
}
</script>
<template>
<Comp ref="target" />
<button type="button" @click="getCompName">Get Comp Name</button>
</template> |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The answer to
defineOptions
is already provided at the beginning above. If you want to declare the name of a route component, please declare it on the route.