Home > Web Front-end > JS Tutorial > body text

Vue introduces jquery to achieve smooth movement

php中世界最好的语言
Release: 2018-05-22 14:29:20
Original
1609 people have browsed it

This time I will bring you Vue to introduce jquery to achieve smooth movement, Vue to introduce jquery to achieve smooth movement. What are the precautions? The following is a practical case, let's take a look.

In the past, the animate implementation of jquery was preferred, but there is no such method in Vue. How to implement click

Navigation to smoothly scroll to the specified position in the Vue project. I was about to collapse for this effect. I searched online for a long time and found that there was no real solution to this problem. I referred to a blogger before. The author’s idea: By scrolling in regular steps within a certain period of time, the effect of smooth scrolling can be seen with the naked eye after continuous operation (click to view). When I saw this article, I was so excited that I quickly referenced the code and wrote it in, but I was confused. . . It had no effect at all. After contacting the blogger for discussion, I came to the conclusion that my vue2.4 version may not be friendly to timers, so I suggested that I downgrade the version. In this case. . . I'd better continue to research how to implement it. In the end, I couldn't find any good method. I introduced jquery and used the animate method to achieve this effect with a few codes.

1.npm install jquery:

npm installjquery--registry=https://<a href="//m.sbmmt.com/wiki/373.html" target="_blank">registry.npm.taobao.org --verbose </a>

2. After successful installation, modify the webpack

configuration file: build--webpack.base.conf.js, and modify it as shown below:

3. Import this jquery plug-in in the script of the vue template, and then you can use it. In my project, navigation and other modules are different components, and then I use the method of transmitting and receiving to operate the index (the method of transmitting and receiving is introduced in detail in my previous blog post, click to view). The smoothing effect mainly depends on what I see in the red box. The code is enough, the other codes are things in my project, no need to consider:

I believe you have mastered the method after reading the case in this article. For more exciting things, please pay attention to php Chinese Other related articles online!

Recommended reading:

JS Promise case code analysis

detailed explanation of node Async/Await asynchronous programming implementation

The above is the detailed content of Vue introduces jquery to achieve smooth movement. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!