1. 程式人生 >程式設計 >vue2+elementui進行hover提示的使用

vue2+elementui進行hover提示的使用


2+elementui進行hover提示分為外部和內部,內部使用el-tooltip,外部使用mouseover和mouseout來讓提示框顯隱(兩個事件要做節流處理,事件要在beforedestroy中銷燬)

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

    <!-- <div slot="content">外部1<br />外部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">多行資訊<br />第二行資訊</div>
          <span>span</span>
        </el-tooltip>
      </li>
    </ol>
    <div v-if="isShow">ol的提示資訊</div>
     <!-- </el-tooltip> -->
  </div>
</template>

<script>
export default {
  name: 'HelloWorlLQmUoLDd',data () {
    return {
      isShow: false,sites: [
        { id: 'sfdsfsd',name: 'Runoob' },{ id: 'sfdsfdfdsd',nLQmUoLDame: 'Google' },{ id: 'sfdssdffsd',name: 'Taobao' }
      ],msg: 'Welcome to Your Vue. 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  to this component only -->
<style scoped>
.list-wrap{
  background-color: #42b983;
}
h1,h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
www.cppcns.com}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

展示效果如下:

vue2+elementui進行hover提示的使用

hover外部:

vue2+elementui進行hover提示的使用

hover裡面span:

vue2+elementui進行hover提示的使用

擴充套件:如果是簡單的hover提示文字(單行或者多行),可以使用::hover偽元素來實現,但是如果要使用html中屬性值作為提示值,新增\A不能換行

到此這篇關於vue2+elementui進行hover提示的使用的文章就介紹到這了,更多相關vue2 elemen客棧t hover提示內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!