Skip to content

Commit

Permalink
update menu demos
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Aug 3, 2016
1 parent 92f5e6c commit 003cf8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 56 deletions.
34 changes: 5 additions & 29 deletions components/menu/demo/basic.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
---
order: 0
order: 1
title: 二级菜单
---



````jsx
import { Menu, Toast } from 'antd-mobile';

let data1 = [
const data = [
{
value: '2',
label: '美食',
Expand Down Expand Up @@ -124,36 +122,14 @@ let data1 = [
},
];

let MenuExample1 = React.createClass({
getInitialState() {
return {
visiable: true,
value: [],
};
},
const MenuExample = React.createClass({
onChange(value) {
Toast.info(`选中了 ${value.toString()}`);
this.setState({
visiable: false,
});
setTimeout(() => {
this.setState({
visiable: true,
value: ['2', '23'],
});
}, 500);
},
render() {
return (<div>
{this.state.visiable ? (<Menu
value={this.state.value}
onChange={this.onChange}
data={data1}
/>) : null}
</div>);
return <Menu data={data} onChange={this.onChange} />
},
});


ReactDOM.render(<MenuExample1 />, mountNode);
ReactDOM.render(<MenuExample />, mountNode);
````
31 changes: 4 additions & 27 deletions components/menu/demo/onelevel.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: 单级菜单
````jsx
import { Menu, Toast } from 'antd-mobile';

let data2 = [
const data = [
{
label: '中餐',
value: '21',
Expand Down Expand Up @@ -50,37 +50,14 @@ let data2 = [
},
];

let MenuExample2 = React.createClass({
getInitialState() {
return {
visiable: true,
value: ['21'],
};
},
const MenuExample = React.createClass({
onChange(value) {
Toast.info(`选中了 ${value.toString()}`);
this.setState({
visiable: false,
});
setTimeout(() => {
this.setState({
visiable: true,
value: ['23'],
});
}, 500);
},
render() {
return (<div>
{this.state.visiable ? (<Menu
level={1}
onChange={this.onChange}
value={this.state.value}
data={data2}
/>) : null}
</div>);
return <Menu data={data} level={1} onChange={this.onChange} />
},
});


ReactDOM.render(<MenuExample2 />, mountNode);
ReactDOM.render(<MenuExample />, mountNode);
````

0 comments on commit 003cf8f

Please sign in to comment.