03c-NavLink组件

Huxzhi小于 1 分钟react18react-router-v6

style 接受一个回调函数 ,会给一个对象 {isActive: Boolean}

<NavLink
  style={
      ({isActive})=>{
          return isActive?
              {backgroundColor:"yellow"}:
              null
      }
  }
  to="/student/2">学生</NavLink>

跟v5 有区别 NavLink