In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "vue how to achieve components to follow the mouse position pop-up effect", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "vue how to achieve components to follow the mouse position pop-up effect" this article.
The card appears when the mouse is placed on my, and the card position follows the mouse. The card is hidden when the mouse removes the card.
When the mouse is moved in, the mouse coordinates are obtained, and the mouse position of the parent component is passed to the child component through prop.
ToCenter (event) {const {XJI y} = event this.mouse_x=x; this.mouse_y=y; this.showCenter=true;}
The child component changes the div coordinates by dynamically binding the style.
Attention!
Instead of using watch at first, you can modify it directly in data, as shown above.
This will cause the data to not get the property values in the prop after the refresh. The figure below is as follows
This can be solved by adding watch to listen for changes in XBI y in prop. The final version is as follows:
Data () {return {content: ['upload profile', 'modify profile', 'exit account', 'online feedback'], sty: {top:'', left:''}}, watch: {x:function (val) {this.sty.left= (val+10) + 'px'}, y:function (val) {this.sty.top= (val+30) +' px'}
By the way, you can close the mouse removal card by adding a mouse removal event to the component.
LeaveCenter () {this.showCenter=false;} above is all the contents of the article "how to achieve the pop-up effect of components following the mouse position in vue". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.