0.1.2 • Published 4 years ago

@stofe/sui-navigation v0.1.2

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

title: 使用文档

sui-navigation

一般用于站点左侧弹出导航, 可以通过单独安装组件或者组件库两种方式使用

组件使用方式

$ snpm install @stofe/sui-navigation --save

import Navigation from '@stofe/sui-navigation'

组件库使用方式

$ snpm install @stofe/sui --save

import { Navigation } from '@stofe/sui'

API

参数说明类型可选值默认值
dataSource菜单内容arraytrue-
activeKey当前选中的节点的key,默认非受控stringfalse-
footer导航栏底部,用于自定义底部内容nodefalsenoop
hasDing是否有固定锚点boolfalsefalse
dingMap固定锚点配置objectfalse{}
onDing固定锚点点击事件funcfalsenoop
onItemClick菜单选中的方法funcfuncnoop
onClose导航关闭funcfuncnoop
iconRendericon函数,默认使用,业务可以自定义函数funcfuncnoop

示例

import { Drawer } from 'next'
import Navigation from '@stofe/sui-navigation'
const dataSource = [
  {
    "title": "财务中心",
    "url": "/page/fin-center",
    "icon": "caiwuzhongxin",
    "children": [
      {
        "title": "报价管理",
        "url": "/page/fin-center/quote",
        "id": "133",
        "disabled": false,
        "index": 10
        "children": [
          {
            "title": "报价资料",
            "url": "/page/fin-center/quote/quote-info/list",
            "id": "134",
            "disabled": false,
            "index": 30
          }
        ],
      }]
    ]
  }
]


class Demo extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: false
    };
  }

  onNavOpen = () => {
    this.setState({ visible: true });
  }

  onNavClose = () => {
    this.setState({ visible: false });
  }

  render() {
    const { visible } = this.state;
    return (
      <div className="demo-container" data-title="DEMO">
        <header>
          <Icon type="toggle-right" size="large" onClick={this.onNavOpen} />
        </header>
        <Drawer
          visible={visible}
          width={440}
          placement="left"
          onClose={this.onNavClose}
          className="demo-drawer"
          bodyStyle={{
            padding: 0,
            height: '100%',
            border: 'none'
          }}
        >
          <Navigation
            dataSource={dataSource}
          />
        </Drawer>
      </div>
    );
  }
}

LICENSE

0.1.2

4 years ago

0.1.1

4 years ago