style: prettier

pull/833/head
tangjinzhou 2019-05-26 13:58:06 +08:00
parent 0a0a6a6103
commit 63fbed0d76
4 changed files with 53 additions and 44 deletions

View File

@ -30,9 +30,11 @@ export default {
}, },
}; };
return ( return (
<div style={{ <div
margin: '100px', style={{
}}> margin: '100px',
}}
>
<div> <div>
<Upload {...uploaderProps}> <Upload {...uploaderProps}>
<a>开始上传</a> <a>开始上传</a>

View File

@ -28,25 +28,29 @@ export default {
// EXAMPLE: post form-data with 'axios' // EXAMPLE: post form-data with 'axios'
const formData = new FormData(); const formData = new FormData();
if (data) { if (data) {
Object Object.keys(data).map(key => {
.keys(data) formData.append(key, data[key]);
.map(key => { });
formData.append(key, data[key]);
});
} }
formData.append(filename, file); formData.append(filename, file);
axios.post(action, formData, { axios
withCredentials, .post(action, formData, {
headers, withCredentials,
onUploadProgress: ({total, loaded}) => { headers,
onProgress({ onUploadProgress: ({ total, loaded }) => {
percent: Math.round((loaded / total) * 100).toFixed(2), onProgress(
}, file); {
}, percent: Math.round((loaded / total) * 100).toFixed(2),
}).then(({data: response}) => { },
onSuccess(response, file); file,
}).catch(onError); );
},
})
.then(({ data: response }) => {
onSuccess(response, file);
})
.catch(onError);
return { return {
abort() { abort() {
@ -65,17 +69,17 @@ export default {
error(err) { error(err) {
console.log('error', err); console.log('error', err);
}, },
progress({ progress({ percent }, file) {
percent,
}, file) {
console.log('progress', `${percent}%`, file.name); console.log('progress', `${percent}%`, file.name);
}, },
}, },
}; };
return ( return (
<div style={{ <div
margin: '100px', style={{
}}> margin: '100px',
}}
>
<div> <div>
<Upload {...uploaderProps}> <Upload {...uploaderProps}>
<a>开始上传</a> <a>开始上传</a>

View File

@ -36,6 +36,6 @@ export default {
background: '#eee', background: '#eee',
}, },
}; };
return <Upload {...uploaderProps}/>; return <Upload {...uploaderProps} />;
}, },
}; };

View File

@ -2,9 +2,9 @@ import Upload from '../index';
export default { export default {
data() { data() {
return {destroyed: false}; return { destroyed: false };
}, },
methods : { methods: {
destroy() { destroy() {
this.destroyed = true; this.destroyed = true;
}, },
@ -64,15 +64,14 @@ export default {
opacity:0.5; opacity:0.5;
`; `;
return ( return (
<div style={{ <div
margin: '100px', style={{
}}> margin: '100px',
}}
>
<h2>固定位置</h2> <h2>固定位置</h2>
<style> <style>{style}</style>
{
style
}</style>
<div> <div>
<Upload {...uploaderProps}> <Upload {...uploaderProps}>
@ -84,19 +83,23 @@ export default {
<div <div
style={{ style={{
height: '200px', height: '200px',
overflow: 'auto', overflow: 'auto',
border: '1px solid red', border: '1px solid red',
}}> }}
<div style={{ >
height: '500px', <div
}}> style={{
height: '500px',
}}
>
<Upload <Upload
{...uploaderProps1} {...uploaderProps1}
component="div" component="div"
style={{ style={{
display: 'inline-block', display: 'inline-block',
}}> }}
>
<a>开始上传2</a> <a>开始上传2</a>
</Upload> </Upload>
</div> </div>