vue修改自带的title属性样式,title属性样式修改办法

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);
    },
posted @ 2019-03-05 11:08  guanqinghua  阅读(426)  评论(0编辑  收藏  举报