2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 6
|
|
|
|
title: 图片列表样式
|
|
|
|
---
|
2015-12-12 15:25:54 +08:00
|
|
|
|
2015-12-27 15:32:37 +08:00
|
|
|
上传文件为图片,可展示本地缩略图。
|
|
|
|
|
2016-04-11 11:52:17 +08:00
|
|
|
`IE8/9` 不支持浏览器本地缩略图展示([Ref](https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL)),可以写 `thumbUrl` 属性来代替。
|
2016-03-31 09:40:55 +08:00
|
|
|
|
2015-12-12 15:25:54 +08:00
|
|
|
````jsx
|
|
|
|
import { Upload, Button, Icon } from 'antd';
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
action: '/upload.do',
|
|
|
|
listType: 'picture',
|
|
|
|
defaultFileList: [{
|
|
|
|
uid: -1,
|
|
|
|
name: 'xxx.png',
|
|
|
|
status: 'done',
|
2015-12-27 15:32:37 +08:00
|
|
|
url: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
|
|
|
|
thumbUrl: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
|
2015-12-12 15:25:54 +08:00
|
|
|
}, {
|
|
|
|
uid: -2,
|
|
|
|
name: 'yyy.png',
|
|
|
|
status: 'done',
|
2015-12-27 15:32:37 +08:00
|
|
|
url: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
|
|
|
|
thumbUrl: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
|
2016-05-11 09:32:33 +08:00
|
|
|
}],
|
2015-12-12 15:25:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
ReactDOM.render(
|
2016-04-29 12:13:27 +08:00
|
|
|
<div>
|
|
|
|
<Upload {...props}>
|
|
|
|
<Button type="ghost">
|
|
|
|
<Icon type="upload" /> 点击上传
|
|
|
|
</Button>
|
|
|
|
</Upload>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<Upload {...props} className="upload-list-inline">
|
|
|
|
<Button type="ghost">
|
|
|
|
<Icon type="upload" /> 点击上传
|
|
|
|
</Button>
|
|
|
|
</Upload>
|
|
|
|
</div>
|
2015-12-29 12:08:58 +08:00
|
|
|
, mountNode);
|
2015-12-12 15:25:54 +08:00
|
|
|
````
|
2016-01-13 22:43:55 +08:00
|
|
|
|
|
|
|
````css
|
|
|
|
/* 加几行样式将上传项变成平铺样式 */
|
|
|
|
.upload-list-inline .ant-upload-list-item {
|
|
|
|
display: inline-block;
|
|
|
|
width: 200px;
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
|
|
|
````
|