vue修改自带的title属性样式,title属性样式修改办法
1.定义id=‘title’:data-title=“itemss.contactsCallTime2” 这个值<divclass="grid-content1 bg-purple-light"id="title" onmouseover="onMouseHover(event)" onmouseout="onMo
·
1.定义id=‘title’ :data-title=“itemss.contactsCallTime2” 这个值
<div class="grid-content1 bg-purple-light"
id="title" onmouseover="onMouseHover(event)" onmouseout="onMouseOut()" :data-title="itemss.contactsCallTime2"
>{{itemss.contactsCallTime2 | filterFun}}</div>
2.定义οnmοuseοver=“onMouseHover(event)” οnmοuseοut=“onMouseOut()” 鼠标事件
鼠标经过时插入样式,鼠标离开时清除样式。
onMouseHover(ev) {
document.styleSheets[0].insertRule('#title::before { left: '+ ev.pageX +'px }', 0);
document.styleSheets[0].insertRule('#title::after { left: '+ ev.pageX +'px }', 0);
},
onMouseOut() {
document.styleSheets[0].deleteRule(0);
document.styleSheets[0].deleteRule(0);
},
更多推荐
已为社区贡献10条内容
所有评论(0)