|
|
|
@ -6,32 +6,57 @@ title: 图片卡片样式
|
|
|
|
|
上传文件为图片,可展示本地缩略图。
|
|
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
|
import { Upload, Icon } from 'antd';
|
|
|
|
|
import { Upload, Icon, Modal } from 'antd';
|
|
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
|
action: '/upload.do',
|
|
|
|
|
listType: 'picture-card',
|
|
|
|
|
defaultFileList: [{
|
|
|
|
|
uid: -1,
|
|
|
|
|
name: 'xxx.png',
|
|
|
|
|
status: 'done',
|
|
|
|
|
url: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
|
|
|
|
|
thumbUrl: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
|
|
|
|
|
}]
|
|
|
|
|
};
|
|
|
|
|
const ImageUploadList = React.createClass({
|
|
|
|
|
getInitialState() {
|
|
|
|
|
return {
|
|
|
|
|
priviewVisible: false,
|
|
|
|
|
priviewImage: '',
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
handleCancel() {
|
|
|
|
|
this.setState({
|
|
|
|
|
priviewVisible: false,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
render() {
|
|
|
|
|
const props = {
|
|
|
|
|
action: '/upload.do',
|
|
|
|
|
listType: 'picture-card',
|
|
|
|
|
defaultFileList: [{
|
|
|
|
|
uid: -1,
|
|
|
|
|
name: 'xxx.png',
|
|
|
|
|
status: 'done',
|
|
|
|
|
url: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
|
|
|
|
|
thumbUrl: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
|
|
|
|
|
}],
|
|
|
|
|
onPreview: (file) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
priviewImage: file.url,
|
|
|
|
|
priviewVisible: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<div className="clearfix">
|
|
|
|
|
<Upload {...props}>
|
|
|
|
|
<Icon type="plus" />
|
|
|
|
|
<div className="ant-upload-text">上传照片</div>
|
|
|
|
|
</Upload>
|
|
|
|
|
<a href="https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png" target="_blank" className="upload-example">
|
|
|
|
|
<img src="https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png" />
|
|
|
|
|
<span>示例</span>
|
|
|
|
|
</a>
|
|
|
|
|
<Modal visible={this.state.priviewVisible} footer={null} onCancel={this.handleCancel}>
|
|
|
|
|
<img src={this.state.priviewImage} />
|
|
|
|
|
</Modal>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
|
<div className="clearfix">
|
|
|
|
|
<Upload {...props}>
|
|
|
|
|
<Icon type="plus" />
|
|
|
|
|
<div className="ant-upload-text">上传照片</div>
|
|
|
|
|
</Upload>
|
|
|
|
|
<a href="https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png" target="_blank" className="upload-example">
|
|
|
|
|
<img src="https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png" />
|
|
|
|
|
<span>示例</span>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
, mountNode);
|
|
|
|
|
ReactDOM.render(<ImageUploadList />, mountNode);
|
|
|
|
|
````
|
|
|
|
|
|
|
|
|
|
````css
|
|
|
|
|