mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
1.4 KiB
1.4 KiB
Uploader
Install
import { Uploader } from 'vant';
Vue.use(Uploader);
Usage
Basic Usage
<div class="uploader-container">
<van-uploader :after-read="onRead">
<van-icon name="photograph" />
</van-uploader>
</div>
export default {
methods: {
onRead(file) {
console.log(file)
}
}
};
Set input attr
You can set native properties such as accpet
、multiple
on Uploader, and the input will automatically inherits the attribute.
<van-uploader :after-read="onRead" accept="image/gif, image/jpeg" multiple>
<van-icon name="photograph" />
</van-uploader>
API
Attribute | Description | Type | Default | Accepted Values |
---|---|---|---|---|
result-type | The way to read the file, read as base64; read as text | String |
dataUrl |
text |
disable | Whether to disable the upload, set to true during the image upload to prevent users from clicking this component to upload pictures | Boolean |
false |
- |
before-read | Hook before reading the file, the first parameter is the selected file, return false to stop reading the file | Function |
- | - |
after-read | Hook after reading the file, parameter format: { file ,content } | Function |
- | - |
Slot
name | Description |
---|---|
- | Custom icon |