ant-design/components/upload/demo/picture-style.md

57 lines
1.3 KiB
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 6
title: 图片列表样式
---
2015-12-12 15:25:54 +08:00
上传文件为图片,可展示本地缩略图。
2016-03-31 09:40:55 +08:00
`IE8/9` 不支持浏览器本地缩略图展示(<a href="https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL">Ref</a>),可以写 `thumbUrl` 属性来代替。
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',
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',
url: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
thumbUrl: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
2015-12-12 15:25:54 +08:00
}]
};
ReactDOM.render(
2016-01-13 22:43:55 +08:00
<div>
2015-12-12 15:25:54 +08:00
<Upload {...props}>
<Button type="ghost">
<Icon type="upload" /> 点击上传
</Button>
</Upload>
2016-01-13 22:43:55 +08:00
<br />
<br />
<Upload {...props} className="upload-list-inline">
<Button type="ghost">
<Icon type="upload" /> 点击上传
</Button>
</Upload>
</div>
, 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;
}
````