添加事件监听进入@mouseover 移出@mouseleave
今天在做web开发有个需求 鼠标移动到图片时候要显示深颜色图片 ,因为我是web开发小白 然后我就是一顿百度,然后看到一堆神操作一大驼代码看的我一懵。 这么简单的一个需求要一堆代码肯定是不可能的。
好吧!还是自己写吧!!! 做开发就是能不自己写就不自己写。嘿嘿 我是这么想的 、我的做法非常简单就是监听事件 然后替换图片路径 直接看代码吧
添加事件监听进入@mouseover 移出@mouseleave
<img @mouseover="eoverLeftArrow()"
@mouseleave="eleaveLeftArrow()"
class="arrow" :src="left_arrow"">
//鼠标移入触发
eoverLeftArrow:function(){
this.right_arrow=this.imgObj.right_arrow_on;
},
//鼠标移出触发
eleaveLeftArrow:function( ){
this.right_arrow=this.imgObj.right_arrow_off;
},