From b0f0e904e88bf1e0df3e1e5d2b32e0c8a56cc49f Mon Sep 17 00:00:00 2001 From: ShanaMaid Date: Wed, 4 Jul 2018 14:32:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(docs):=20=E4=BC=98=E5=8C=96=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BD=91=E7=AB=99=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Backtop/assist.tsx | 2 +- docs/pages/index.tsx | 56 +++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/components/Backtop/assist.tsx b/components/Backtop/assist.tsx index 008b927..22748c2 100644 --- a/components/Backtop/assist.tsx +++ b/components/Backtop/assist.tsx @@ -1,4 +1,4 @@ -export const backTop = (durations: number, callback: () => void | undefined) => { +export const backTop = (durations: number, callback?: () => void | undefined) => { let dom: HTMLElement; if (document.documentElement.scrollTop) { dom = document.documentElement; diff --git a/docs/pages/index.tsx b/docs/pages/index.tsx index 31fbcb0..fa64482 100644 --- a/docs/pages/index.tsx +++ b/docs/pages/index.tsx @@ -3,15 +3,14 @@ import { Component } from 'react'; import { Switch, Route, Redirect } from 'react-router-dom'; import { Link } from 'react-router-dom'; import {Menu, BackTop} from '../../components/'; +import { backTop } from '../../components/BackTop/assist'; import './index.less'; import menuObj from './menu'; import { MenuItem } from '../../components/Menu/MenuItem'; import { RouteComponentProps } from 'react-router'; import Routes from './routes'; - -export interface IProps extends RouteComponentProps<{name: string}>{ - +export interface IProps extends RouteComponentProps<{name: string}> { } const SubMenu = Menu.SubMenu; @@ -19,11 +18,12 @@ const MenuItemGroup = Menu.ItemGroup; export default class Components extends Component { pushHistory = (url: string) => { - this.props.history.push('/components/' + url) + this.props.history.push('/components/' + url); + backTop(300); } render() { - const preCls = 'wrapper' + const preCls = 'wrapper'; const current = this.props.match.params.name; return (
@@ -39,24 +39,30 @@ export default class Components extends Component { defaultActiveKey={current} defaultOpenKeys={['components']} > - Yoshino - 快速开始 - 更新日志 - FAQ - + Yoshino + 快速开始 + 更新日志 + FAQ + { - menuObj.map((item) => { + menuObj.map((menu) => { return ( - + { - item.children.map((item) => { + menu.children.map((item) => { return ( - {item.name} - ) + + {item.name} + + ); }) } - ) + ); }) } @@ -68,19 +74,19 @@ export default class Components extends Component { Routes.map((item, key) => { return ( - ) + ); }) } - { - return - }}/> + { + return ; + }} + />
-
- -
+
- ) + ); } -}; +}