[Vuejs] 給ref賦值須要注意的問題

一、簡單賦值this

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

訪問方式:spa

this.$refs.refCon

二、循環賦值,相同名稱code

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

訪問方式:blog

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

三、循環賦值,不一樣名稱class

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

訪問方式:循環

this.$refs.refCon0[0]
this.$refs.refCon1[0]
相關文章
相關標籤/搜索