zoukankan      html  css  js  c++  java
  • vue 点击显示隐藏,鼠标移动上去显示隐藏

    1,鼠标点击显示隐藏,样式可以自己调,我就写个dome。


    <div class="min"> <button @click="change">点击我</button> <div v-show="show"> 显示隐藏的内容 </div> </div>

    <script>
    export default {
      name: "testresult",
      data() {
        return {
          show: false
        };
      },
      methods: {
        change() {
          this.show = !this.show;
        }
      }
    };
    </script>


    鼠标移动上去事件:

    html:

      <div class="min">
          <button
            class="cancelbtn"
            @mouseover="mouseover(n)"
            @mouseleave="mouseleave"
            v-show="isshow & (n == id)"
          >
            取消</button
          ><br />
          <button
            class="followbtn"
            @mouseover="mouseover(n)"
            @mouseleave="mouseleave"
          >
            关注
          </button>
        </div>
    View Code

    js

    <script>
    export default {
      name: "testresult",
      data() {
        return {
          isshow: false,
          id: 0
        };
      },
      methods: {
        // 移入
        mouseover(id) {
          this.id = id;
          clearTimeout(this.timer);
          this.isshow = true;
        },
        // 移出
        mouseleave() {
          this.timer = setTimeout(() => {
            this.isshow = false;
          }, 100);
        }
      }
    };
    </script>
    View Code

    css:

    .followbtn {
       50px;
      height: 30px;
      text-align: center;
      background-color: coral;
      color: #ffffff;
      border: 0;
    }
    .cancelbtn {
       50px;
      height: 30px;
      text-align: center;
      background-color: brown;
      color: #ffffff;
      border: 0;
    }

    效果图:

       

  • 相关阅读:
    在Centos中导入sql文件的方法
    Centos7.4 版本环境下安装Mysql5.7操作记录
    CentOS 7.4下使用yum安装MySQL5.7.20 最简单的
    MySql命令集合
    常用linux命令
    HDP Spark2 HIVE3.1 的问题
    YARN 的调度选项
    Sqoop 遇到的问题
    Kubernetes 集群部署(4) -- Node 部署
    HDP 中 yarn 和 MR2 的配置
  • 原文地址:https://www.cnblogs.com/lovebear123/p/12069245.html
Copyright © 2011-2022 走看看