forked from ant-design/ant-design-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Image picker feature, add file accept (ant-design#2269)
* add file accept in image-picker * add file accept in image-picker * add file accept in image-picker
- Loading branch information
1 parent
9645e86
commit d43e38f
Showing
6 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
components/image-picker/__tests__/__snapshots__/demo.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
order: 2 | ||
title: | ||
zh-CN: 自定义文件类型 | ||
en-US: 'Cutom file accept' | ||
--- | ||
|
||
````jsx | ||
import { ImagePicker } from 'antd-mobile'; | ||
|
||
const data = [{ | ||
url: 'https://zos.alipayobjects.com/rmsportal/PZUUCKTRIHWiZSY.jpeg', | ||
id: '2121', | ||
}, { | ||
url: 'https://zos.alipayobjects.com/rmsportal/hqQWgTXdrlmVVYi.jpeg', | ||
id: '2122', | ||
}]; | ||
|
||
class ImagePickerExample extends React.Component { | ||
state = { | ||
files: data, | ||
} | ||
onChange = (files, type, index) => { | ||
console.log(files, type, index); | ||
this.setState({ | ||
files, | ||
}); | ||
} | ||
|
||
render() { | ||
const { files } = this.state; | ||
return ( | ||
<div> | ||
<ImagePicker | ||
files={files} | ||
onChange={this.onChange} | ||
onImageClick={(index, fs) => console.log(index, fs)} | ||
selectable={files.length < 5} | ||
accept="image/gif,image/jpeg,image/jpg,image/png" | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
ReactDOM.render(<ImagePickerExample />, mountNode); | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters