删除elementplus的li标签中的一个class属性?
问:
删除elementplus的li标签中的一个class属性?
回答:
<el-sub-menu@click="handleClickSubMenu(item, $event)"const handleClickSubMenu = async (e: any, item: Event) => {...await nextTick()const target = item.currentTarget as HTMLElementtarget.classList.remove('is-active')
通过使用$event ,首先使用nextTick,要是不使用即使后面可以获取is-active属性也无法remove删除。
使用item.currentTarget 获取元素节点的所有class类
使用remove删除 is-active 属性