<div>
<span v-for="(item,index) in list" :key="index" :ref="'spanRef' + index" :id="'spanRef' + index">{{item.label}}</span>
</div>
list: [
{
id: 1,
label: 1
},
{
id: 2,
label: 2
},
{
id: 3,
label: 3
},
]
mounted() {
this.$nextTick(() => {
for (let i = 0; i < this.list.length; i++) {
const element = this.list[i];
console.log('i====>', this.$refs['spanRef' + i]);
console.log('document===>', document.getElementById("spanRef" + i));
}
})
},