一 点击高亮
- 在data内设置当前点击事件的位置 控制高亮
eg : iCurrent : 0
- 在标签中设置对应类名 当当前
i
===iCurrent
的时候出现样式
其次标签的点击事件中传入当前i
值
在函数中将当前iCurrent
值设置等于i
二 无法跳转路由
this . props . history . push ( ' 路径 ')
或者是goBack()
只能用在参与路由的组件中使用
未参与路由的组件 不能使用 原因 : 组件的props
上没有history
属性
使用方法 ( 使用 withRouter
包裹组件 )
导入 import {withRouter} from ' react-router-dom '
使用 let 名称 = withRouter{ 需要包裹的组件名 }
名称代替原先组件的地方