[Vuejs] 给ref赋值需要注意的问题

1、简单赋值

<div ref="refCon"></div>

访问方式:

this.$refs.refCon

2、循环赋值,相同名称

<div v-for="i in 2" ref="refCon"></div>

访问方式:

this.$refs.refCon[0]
this.$refs.refCon[1]

3、循环赋值,不同名称

<div v-for="i in 2" :ref="`refCon${i}`"></div>

访问方式:

this.$refs.refCon0[0]
this.$refs.refCon1[0]
原文地址:https://www.cnblogs.com/frost-yen/p/11145791.html