鼠标跟随效果 vue或者js通用

this.$refs.tooltip.getBoundingClientRect() => 用于获取某个元素相对于视窗的位置集合。集合中有top, right, bottom, left等属性。
鼠标跟随:

e.clientX - this.$refs.tooltip.getBoundingClientRect().width/2
e.clientY - this.$refs.tooltip.getBoundingClientRect().height

效果:

猜你喜欢

转载自www.cnblogs.com/fmixue/p/10065128.html
今日推荐