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);
},