index.js 1.26 KB
Newer Older
zhanghaozhe committed
1 2 3 4 5 6 7 8
import React from 'react';
import { NavLink } from 'react-router-dom'
import './index.scss';

const navLinkConfig = [
    {
        to: '/',
        exact: true,
xuzhenghua committed
9
        icon: 'iconshouye-xianxing',
zhanghaozhe committed
10 11 12 13 14
        text: '首页'
    },
    {
        to: '/classify',
        exact: false,
xuzhenghua committed
15
        icon: 'iconfenlei-xianxing',
zhanghaozhe committed
16 17 18 19 20
        text: '分类'
    },
    {
        to: '/study',
        exact: false,
xuzhenghua committed
21
        icon: 'iconxuexi-xianxing',
zhanghaozhe committed
22 23 24 25 26
        text: '学习'
    },
    {
        to: '/my',
        exact: false,
xuzhenghua committed
27
        icon: 'iconwode-xianxing',
zhanghaozhe committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
        text: '我的'
    }
]

const NavBar = React.memo(() => {
    return (
        <div className="nav-bar">
            {
                navLinkConfig.map(item => {
                    let {icon, text, ...rest} = item
                    return (
                        <NavLink
                            activeClassName={'active'}
                            className={'nav-item'}
                            key={icon}
                            {...rest}
                        >
                            <i className={`iconfont ${icon}`}/>
                            <span>{text}</span>
                        </NavLink>
                    )
                })
            }
        </div>
    )
})

export default NavBar