vue3.0设置dom动态ref值及获取

2023-04-11  本文已影响0人  花影_62b4

设置动态ref ---- :ref=字符串直接+变量的形式赋值

<template v-for="(item, i) in stepList" :key="i">
<h-b-upload
            :ref="'uploadRef' + i"
            accept="image/*"
            :draggable="false"
            :multiple="true"
            :show-upload-list="false"
            :fileList="fileList"
            filePath="/capp/"
            @change="file => changeFile(file, i)"
          ></h-b-upload>
</template >

setup中获取动态ref ---- instance.refs['uploadRef' + index][0]

const instance = getCurrentInstance();
instance.refs['uploadRef' + index][0]
上一篇下一篇

猜你喜欢

热点阅读