vue中CSS使用:after伪类实现点击改变样式

1.如图
在这里插入图片描述
在这里插入图片描述
2.实现

data中actived一开始为false

在这里插入图片描述
方法中
gbys () {
this.ddh = JSON.parse(window.localStorage.getItem(‘ddh’))
console.log(this.yhid)
console.log(this.fxid)
this.actived = !this.actived
console.log(this.actived)
},
在这里插入图片描述
style中
.actived{
position: relative;
border: 1px solid red !important;
}
.actived:after{
content: ‘’;
background: url(’…/…/assets/img/duigou.png’) no-repeat bottom right;
position: absolute;
width: 45px;
height: 45px;
bottom: 0;
right: 0;
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/WQzeus/article/details/109909664