Use vue2+elementui for hover prompts

Use vue2+elementui for hover prompts

Vue2+elementui's hover prompts are divided into external and internal. The internal one uses el-tooltip, and the external one uses mouseover and mouseout to make the prompt box appear and disappear (the two events need to be throttled, and the events must be destroyed in beforedestroy)

<template>
  <div class="hello">
<!-- <el-tooltip placement="top"> -->

    <!-- <div slot="content">External 1<br />External 2</div> -->
    <ol class="list-wrap" @mouseover.stop="mouseover" @mouseout.stop="mouseout">
      <li v-for="site in sites"
          :key="site.id">
        <el-tooltip placement="top">
          <div slot="content">Multiple lines of information<br />Second line of information</div>
          <span>span</span>
        </el-tooltip>
      </li>
    </ol>
    <div v-if="isShow">ol's prompt information</div>
     <!-- </el-tooltip> -->
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      isShow: false,
      sites: [
        { id: 'sfdsfsd', name: 'Runoob' },
        { id: 'sfdsfdfdsd', name: 'Google' },
        { id: 'sfdssdffsd', name: 'Taobao' }
      ],
      msg: 'Welcome to Your Vue.js App'
    }
  },
  methods: {
    mouseover (e) {
      if (e.target.tagName === 'OL') {
        this.isShow = true
        console.log('enter', e.target.tagName)
      }
    },
    mouseout (e) {
      if (e.target.tagName === 'OL') {
        console.log('leave', e.target.tagName)
        this.isShow = false
      }
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.list-wrap{
  background-color: #42b983;
}
h1,
h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

The display effect is as follows:

Hover external:

Hover inside span:

Extension: If it is a simple hover prompt text (single or multiple lines), you can use the ::hover pseudo-element to implement it, but if you want to use the attribute value in HTML as the prompt value, adding \A will not wrap the line

This is the end of this article about the use of vue2+elementui for hover prompts. For more relevant vue2 element hover prompt content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Vue+ElementUI implements paging function-mysql data
  • Vue+elementui realizes multiple selection and search functions of drop-down table
  • Vue Element-ui implements tree control node adding icon detailed explanation
  • Detailed explanation of the use of ElementUI in Vue
  • How to install Element UI and use vector graphics in vue3.0

<<:  Docker uses root to enter the container

>>:  Supplementary article on front-end performance optimization

Recommend

About WSL configuration and modification issues in Docker

https://docs.microsoft.com/en-us/windows/wsl/wsl-...

Vertical and horizontal splitting of MySQL tables

Vertical Split Vertical splitting refers to the s...

Linux file and user management practice

1. Display the files or directories in the /etc d...

25 Vue Tips You Must Know

Table of contents 1. Limit props to type lists 2....

Teach you how to implement a react from html

What is React React is a simple javascript UI lib...

Detailed explanation of MYSQL stored procedure comments

Table of contents 1. Instructions for use 2. Prep...

MySQL full-text search usage examples

Table of contents 1. Environmental Preparation 2....

Solution to occasional crash of positioning background service on Linux

Problem Description In the recent background serv...

Detailed explanation of Angular routing basics

Table of contents 1. Routing related objects 2. L...

A brief discussion on why daemon off is used when running nginx in docker

I'm very happy. When encountering this proble...

MySQL 8.0.24 version installation and configuration method graphic tutorial

This article records the installation and configu...

18 common commands in MySQL command line

In daily website maintenance and management, a lo...

Detailed deployment of docker+gitlab+gitlab-runner

environment Server: centos7 Client: window Deploy...

Vue implements zip file download

This article example shares the specific code of ...

3D tunnel effect implemented by CSS3

The effect achievedImplementation Code html <d...