react v6 函数组件跳转
作者:互联网
import { useNavigate } from "react-router-dom"; function Menu() { const navigate = useNavigate(); function menuClick(val) { /***/ navigate(val.path); /***/ } return ( <div className="menu"> {menu.map((item, index) => ( <div key={index} onClick={() => { menuClick(item); }} > <span>{item.icon}</span> <span>{item.title}</span> </div> ))} </div> ); }
标签:function,val,navigate,menuClick,react,item,v6,跳转 来源: https://www.cnblogs.com/newBugs/p/15968469.html