How can I achieve this naming pattern for sequentially rendering instances of <BaseComponent>
in vue without utilizing a for
loop, Array.from
, or passing additional props?
#9279
Unanswered
amantiwari1
asked this question in
Help/Questions
Replies: 1 comment
-
<template>
<div>Comp-{{ uid }}</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
let uid = 0;
export default defineComponent({
setup() {
uid += 1;
return { uid };
},
});
</script> <script lang="ts" setup>
import Comp from './Comp.vue';
</script>
<template>
<Comp />
<Comp />
<Comp />
</template> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How can I achieve this naming pattern for sequentially rendering instances of
<BaseComponent>
in vue without utilizing afor
loop,Array.from
, or passing additional props?Provide 3 instances of the component without any props:
In the browser, it will display as follows:
base-component-1
base-component-2
base-component-3
If you add one more
<BaseComponent />
, it will be displayed asbase-component-4
, for example.When you input 4 components without props:
The output in the browser will appear like this:
base-component-1
base-component-2
base-component-3
base-component-4
So, how can I achieve this without using a for loop, Array.from, or props?
Beta Was this translation helpful? Give feedback.
All reactions