Skip to content

Commit

Permalink
feat: 更新 image upload 组件的
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondYuan committed Dec 11, 2023
1 parent a01a7d7 commit 21f1830
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 59 deletions.
11 changes: 5 additions & 6 deletions compiled/alipay/demo/pages/ImageUploadControl/index.axml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<container title="受控模式">
<uploader
fileList="{{fileList}}"
fileList="{{ fileList }}"
onChange="onChange"
onUpload="onUpload" />
</container>

<container title="手动触发上传">
<uploader
ref="handleUploaderRef"
fileList="{{fileList}}"
fileList="{{ fileList }}"
onChange="onChange"
onUpload="onUpload" />
<button
size="default"
<ant-button
size="medium"
onTap="upload"
type="primary">
上传
</button>
</ant-button>
</container>
62 changes: 31 additions & 31 deletions compiled/alipay/demo/pages/ImageUploadControl/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
Page({
data: {
fileList: [{
url: 'https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*znK_ToIL8rQAAAAAAAAAAAAAARQnAQ',
status: 'done',
}, {
url: 'https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*kStORbDQxwMAAAAAAAAAAAAAARQnAQ',
status: 'pending',
}, {
url: 'https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*K4Z-RLHuliYAAAAAAAAAAAAAARQnAQ',
status: 'error',
}],
},
onChange(fileList) {
this.setData({
fileList,
});
},
handleUploaderRef(ref){
this.handleUploaderRef = ref;
},
upload(){
this.handleUploaderRef.chooseImage()
},
onUpload(file) {
console.log('当前上传的图片为:', file);
return new Promise((resolve) => {
setTimeout(() => {
resolve('https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ');
}, 2000);
})
},
data: {
fileList: [{
url: 'https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*znK_ToIL8rQAAAAAAAAAAAAAARQnAQ',
status: 'done',
}, {
url: 'https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*kStORbDQxwMAAAAAAAAAAAAAARQnAQ',
status: 'pending',
}, {
url: 'https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*K4Z-RLHuliYAAAAAAAAAAAAAARQnAQ',
status: 'error',
}],
},
onChange: function (fileList) {
this.setData({
fileList: fileList,
});
},
handleUploaderRef: function (ref) {
this.handleUploaderRef = ref;
},
upload: function () {
this.handleUploaderRef.chooseImage();
},
onUpload: function (file) {
console.log('当前上传的图片为:', file);
return new Promise(function (resolve) {
setTimeout(function () {
resolve('https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ');
}, 2000);
});
},
});
3 changes: 2 additions & 1 deletion compiled/alipay/demo/pages/ImageUploadControl/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"defaultTitle": "ImageUpload",
"usingComponents": {
"uploader": "../../../src/ImageUpload/index",
"ant-button": "../../../src/Button/index",
"container": "../../../src/Container/index"
}
}
}
Empty file.
20 changes: 0 additions & 20 deletions demo/pages/ImageUploadControl/index.axml

This file was deleted.

23 changes: 23 additions & 0 deletions demo/pages/ImageUploadControl/index.axml.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { InternalData } from 'tsxml';
import Container from '../../../src/Container/index.axml';
import Uploader from '../../../src/ImageUpload/index.axml';
import AntButton from '../../../src/Button/index.axml';

export default (_: any, { fileList }: InternalData) => (
<Page>
<Container title="受控模式">
<Uploader fileList={fileList} onChange="onChange" onUpload="onUpload" />
</Container>
<Container title="手动触发上传">
<Uploader
ref="handleUploaderRef"
fileList={fileList}
onChange="onChange"
onUpload="onUpload"
/>
<AntButton size="medium" onTap="upload" type="primary">
上传
</AntButton>
</Container>
</Page>
);
3 changes: 2 additions & 1 deletion demo/pages/ImageUploadControl/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"defaultTitle": "ImageUpload",
"usingComponents": {
"uploader": "../../../src/ImageUpload/index",
"ant-button": "../../../src/Button/index",
"container": "../../../src/Container/index"
}
}
}
File renamed without changes.
File renamed without changes.

0 comments on commit 21f1830

Please sign in to comment.