首页 > 解决方案 > 有什么办法可以使用 document.getElementById 两次?

问题描述

我想在按钮槽上悬停时添加类,但是对于每个房间,槽都有相同的 id,所以 document.getElementById 不能按要求工作。有什么办法可以访问每个房间的插槽吗?我正在研究 Vue.js 在此处 输入图像描述

<w-col v-for="room in rooms" :id="room.dsid" :key="room.dsid" class="col">
                <ImageTitle
                    :id="room.dsid"
                    :name="room.space_name+' '+room.building_name"
                    :src="room.image_url"
                    @infoClick="showPopOver"
                ></ImageTitle>
                <div v-for="(n,index) in 48" :key="index" class="slot">
                    <w-button :id="n" raw class="slots" :class="{ 'border-top': index === 0 || index%4 === 0, 'border-bottom': index === 47}" @mouseover.native="mouseOver(n, room.dsid)" @mouseleave.native="mouseLeave()" @click="selectSlot(n, room.name)">
                        <w-row></w-row>
                    </w-button>
                </div>
</w-col>

标签: javascripthtmlvue.js

解决方案


推荐阅读