vue中轻松搞掂鼠标气泡框提示框tip跟随
生活随笔
收集整理的這篇文章主要介紹了
vue中轻松搞掂鼠标气泡框提示框tip跟随
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
?
<template><div><!-- 提示框 --><sg-tip :show="isShowTip">{{tipContent}}</sg-tip><!-- 移入某個元素觸發顯示跟隨提示框顯示--><div class="red" @mouseover="showTip($event.target.innerText)" @mouseout="hideTip"><p>The current baseline outlook for suggests</p></div></div>
</template><script>export default {data() {return {isShowTip: false,tipContent: ""};},mounted() {this.mouseFllow();},methods: {showTip(text = "") {this.tipContent = text;this.isShowTip = true;},hideTip() {this.isShowTip = false;},mouseFllow() {// 鼠標跟隨tipvar sgTip = document.querySelector("sg-tip");document.onmousemove = function (e) {var x = e.pageX,y = e.pageY,offset = 20;sgTip.style.left = x + offset + "px";sgTip.style.top = y + offset + "px";};}}};
</script>
總結
以上是生活随笔為你收集整理的vue中轻松搞掂鼠标气泡框提示框tip跟随的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vue获取“分享给朋友”按钮点击状态及自
- 下一篇: 【记录】我在团队合作中遇到过的胎神(扑街