提交 f88c8f16 authored 作者: 钟是志's avatar 钟是志

2019年9月24日 12:38:44

上级 07293ed8
......@@ -8,24 +8,19 @@ export default class UploadButton extends React.Component {
}
clickUpload = (e) => {
if(e && e.stopPropagation){
e.stopPropagation();
e.preventDefault();
}
// alert(window.navigator.userAgent);
// document.getElementById('infoUpload').click();
this.fileInput.click();
this.fileInput.click();
};
imgFileChange = (e) => {
if(e && e.stopPropagation){
e.stopPropagation();
e.preventDefault();
}
const file = this.fileInput.files[this.fileInput.files.length - 1];
if(!file) {
return false;
}
Toast.loading();
Toast.loading('文件上传中', 0);
uploadFile({file}).then((res) => {
Toast.hide();
if(res && res.url){
......@@ -46,21 +41,35 @@ export default class UploadButton extends React.Component {
render() {
return (
<div style={{fontSize: '18px',paddingTop: '10px',paddingBottom: '10px'}} >
<div style={{
fontSize: '18px',
paddingTop: '10px',
paddingBottom: '10px',
position: 'relative'
}} >
<p
/* onClick={this.clickUpload}*/
style={{
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
textAlign: 'center',
lineHeight: '46px',
margin: 'auto',
}}>
上传
</p>
<input type="file"
accept={'image/*'}
id={'infoUpload'}
style={{ display: 'none' }}
style={{ opacity: 0 }}
onChange={this.imgFileChange}
ref={input => {
this.fileInput = input;
}}
/>
<p onClick={this.clickUpload} style={{textAlign: 'center'}}>
上传
</p>
</div>
)
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论