<ul class="q-main-u">
<li v-for="(subitem,subindex) in quectionList" ref="list" :key="subindex">
<span>{{subitem.text}}</span>
</li>
</ul>
以上,是for循環渲染出來的一個列表,給li添加ref,
在需要給具體的某一個添加樣式的時候可以這樣寫
this.$refs.list[i].style.backgroundColor="rgba(214,37,80,.5)"
其中this.$refs.list為查詢到的所有的li,
this.$refs.list[i],根據索引找到其中需要的某一個li,
給這個li添加一個背景顏色,必須寫成backgroundColor,不能寫background-color形式;
背景色是可以使用rgba()形式的;
添加其他樣式也是同樣的寫法。
的
的的
的的的
。。。。。。