mounted (){
       document.getElementById("side-bar").addEventListener("click",function(event){
         if(this.zhongjian==null){}else{this.zhongjian.style="background-color:#08ac9c";
         this.zhongjian}
         this.zhongjian=event.target;
            event.target.style="background-color:#19c499;";
            console.log("event.target==="+event.target)
    },true);

zhongjian用来记录上一个被点击的div

该功能实现了,但是现在新的问题来了,js会改变div的hover样式

解决方法在下面这个帖子:

https://blog.csdn.net/qq_30815659/article/details/123584310

Logo

前往低代码交流专区

更多推荐