Grid 九宫格
定义/Definition
卡片可以控制和组织信息,通常是更复杂或详细信息的切入点。
规则 / Rule
九宫格内文本最长不超过五个字符。
代码演示
基本
import { Grid } from 'antd-mobile';
let data1 = [
{
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
},
];
let GridExample = React.createClass({
render() {
return (<div>
<Grid data={data1} />
</div>);
},
});
ReactDOM.render(<GridExample />, mountNode);
没有边线
import { Grid } from 'antd-mobile';
let data2 = [
{
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
},
];
let GridExample = React.createClass({
render() {
return (<div>
<Grid
data={data2}
hasLine={false}
/>
</div>);
},
});
ReactDOM.render(<GridExample />, mountNode);
走马灯有边线
import { Grid } from 'antd-mobile';
let data3 = [
{
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
},
];
let GridExample = React.createClass({
render() {
return (<div>
<Grid
data={data3}
isCarousel
onClick={(el, index) => { alert(index); }}
needActive={false}
/>
</div>);
},
});
ReactDOM.render(<GridExample />, mountNode);
走马灯没有边线
import { Grid } from 'antd-mobile';
let data4 = [
{
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
}, {
icon: 'https://os.alipayobjects.com/rmsportal/IptWdCkrtkAUfjE.png',
text: '名字',
link: 'hehe',
},
];
let GridExample = React.createClass({
render() {
return (<div>
<Grid
data={data4}
hasLine={false}
isCarousel
/>
</div>);
},
});
ReactDOM.render(<GridExample />, mountNode);
API
Grid
成员 | 说明 | 类型 | 可选值 | 默认值 |
---|
data | 传入的菜单数据 | Array,每个元素必须包含icon ,和text 两个key | | [] |
onClick | 点击每个菜单的回调 | Function(el, index) | | |
hasLine | 是否有边框 | bollean | | true |
isCarousel | 是否跑马灯, | bollean | | false |