zoukankan      html  css  js  c++  java
  • 一个vue的循环列表,里面的按钮的移入事件

    需求:移入的时候,互相关注变成取消关注

    移入移出事件传参$event,把这个参数打印出来看就可以搞定,而不是移入的时候,文本都改变,只改变当前行 的文本

    <p  @mouseover="over($event)" @mouseout="out($event)">互相关注</p>


    out (t) {
    t.target.innerText = '互相关注'
    },
    over (t) {
    console.log(t, 1)
    console.log(t.target.innerText, 1)
    t.target.innerText = '取消关注'
    },

     不能这么写,这么写的话ie10点击取消关注会卡死,应为mouseover有冒泡,这里应该用mouseenter只在当前,不用event

    ****************************************************************************************************

    ****************************************************************************************************

    最好这么写

    <p class="focus-span" v-if="item.concernStatus==2" @click="focusTogether(item.userId)" @mouseenter="over" @mouseleave="out">{{msg}}</p>
    data里面
    msg:'互相关注'
    out () {
    this.msg = '互相关注'
    },
    over () {
    this.msg = '取消关注'
    },
    不论鼠标指针穿过被选元素或其子元素,都会触发 mouseover 事件。对应mouseout;相当于有冒泡
    只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件。对应mouseleave

    这样的话,mouseenter子元素不会反复触发事件,否则在IE中经常有闪烁情况发生。这就时为啥ie兼容的时候要卡死

  • 相关阅读:
    ubuntu 系统命令
    js模板引擎实例一
    读取页面上所有的checkbox
    使用fileReader实现图片预览
    html5中的audio标签针对IOS系统的兼容处理
    CSS单位
    使用变换属性的旋转和动画属性实现大风车效果
    css动画属性--轮播图效果
    php curl详解
    linux权限详解
  • 原文地址:https://www.cnblogs.com/myfirstboke/p/9150809.html
Copyright © 2011-2022 走看看