vue3 v-for循环子组件上绑定ref并且取值
// 要循环的变量
const views= ref([])
// 数组存所有ref dom
const itemsRef = ref([])
const refresh = (index) => {
// 取出ref dom子组件并且调用其方法
itemsRef.value[index].initChart()
}
<div class="block" v-for="(item, index) in views" :key="item.id">
<reactive-chart :chartMeta="item" :ref="(el) => (itemsRef[index] = el)"></reactive-chart>
</div>
7453

被折叠的 条评论
为什么被折叠?



