Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

how to use @Ref declare with ref in v-for element #410

Open
Lassell opened this issue Nov 10, 2021 · 2 comments
Open

how to use @Ref declare with ref in v-for element #410

Lassell opened this issue Nov 10, 2021 · 2 comments

Comments

@Lassell
Copy link

Lassell commented Nov 10, 2021

<template>
    <div>
        <div v-for="index in 10" :key="index" :ref="'No:'+index">
        	{{index}}    
    	</div>
    </div>
</template>

<script lang="ts">
import {Ref,Options,Vue} from 'vue-property-decorator'
export default Text extends Vue{
    //how to declare
    @Ref() ... 
}
</script>
@huangbh1024
Copy link

I have the same problem, how did you solve it

@jaredmcateer
Copy link

jaredmcateer commented Jun 9, 2022

instead of making the name dynamic make it a static name and Vue makes the template Ref an array

<template>
    <div>
        <div v-for="index in 10" :key="index" ref="myRefs">
        	{{index}}    
    	</div>
    </div>
</template>

<script lang="ts">
import {Ref,Options,Vue} from 'vue-property-decorator'
export default Text extends Vue{
    @Ref() myRefs!: HTMLDivElement[];
}
</script>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants