📜  NavLink - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:26.947000             🧑  作者: Mango

代码示例2
// React Router v6
import { NavLink } from 'react-router-dom';

function NavBar() {
  // inline or css classes
  let activeStyle = { color: 'green', textDecoration: 'underline' };
  let activeClass = 'activated';

  return (
    
  );
}
// Special kind of  that knows when it is 'active'
// the styling applies to a  when route it links to
// is currently selected.
/* 
 index.css
     a, .nav-link { color: 'blue', text-decoration: 'none' }
    .activated { color: 'green', text-decoration: 'underline' }
*/

// React Router v5
function NavBar() {  
  return (
    
  );
}