react實現(xiàn)路由動畫跳轉(zhuǎn)功能
react路由動畫跳轉(zhuǎn)
1.先在react項目中下載一個css第三方庫。用npm或者yarn
// 第三方庫下載 npm install animate.css --save yarn add animate.css
2.在react組件中引用這個css庫
// 引用庫 import 'animate.css';
3 .引用到組件中
// 引用到組件中
import React,{useEffect,useState} from 'react'
import 'animate.css';4.因為react只有一個根節(jié)點,在最外層的盒子給一個classname名稱
<div class="animate__animated animate__bounce">An animated element</div>
5.創(chuàng)建一個css文件,引用到組件
.my-element {
display: inline-block;
margin: 0 0.5rem;
animation: bounce; /* referring directly to the animation's @keyframe declaration */
animation-duration: 2s; /* don't forget to set a duration! */
}
/* This only changes this particular animation duration */
.animate__animated.animate__bounce {
--animate-duration: 2s;
}
/* This changes all the animations globally */
:root {
--animate-duration: 800ms;
--animate-delay: 0.9s;
}6 .css動畫網(wǎng)址 鏈接: 點擊到https://animate.style/
7.總結(jié):
下載 第三方庫 引用
創(chuàng)建 css文件,引用
那個組件想要實現(xiàn)跳轉(zhuǎn)動畫功能,就在那個組件的根節(jié)點綁定classname屬性即可
在跳轉(zhuǎn)的時候即可實現(xiàn)
到此這篇關(guān)于react路由動畫跳轉(zhuǎn)的文章就介紹到這了,更多相關(guān)react路由動畫內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
React Fiber構(gòu)建beginWork源碼解析
這篇文章主要為大家介紹了React Fiber構(gòu)建beginWork源碼解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-02-02
使用React hook實現(xiàn)remember me功能
相信大家在使用 React 寫頁面的時候都遇到過完成 Remember me 的需求吧!本文就將這個需求封裝在一個 React hook 中以供后續(xù)的使用,覺得有用的同學(xué)可以收藏起來以備不時之需,感興趣的小伙伴跟著小編一起來看看吧2024-04-04

