* fix: Tabbar icon line-height * [new feature] progress add showPivot prop * [new feature] TabItem support vue-router * [new feature] update document header style * [Doc] add toast english ducoment * [bugfix] Search box-sizing wrong * [Doc] update vant-demo respo * [Doc] translate theme & demo pages * [Doc] add Internationalization document * [bugfix] remove unnecessary props * [fix] optimize clickoutside * [new feature] optimize find-parent * [new feature]: change document title accordinng to language * [new feature] Pagination code review * [improvement] adjust icon-font unicode * [improvement] Icon spinner color inherit * [improvement] icon default width * [bugfix] DateTimePicker validate date props * [bugfix] Tab item text ellipsis * [improvement] optimize single line ellipsis * [Improvement] optimzie staticClass * [Improvement] Button: use sfc instread of jsx * [Improvement] update actionsheet close icon style * fix: yarn.lock * fix: icon test cases * [bugfix] errors during ssr * [Improvement] SubmitBar add left slot * [new feature] ImagePreview support manually close * fix: ImagePreview test case * [Doc] add switch lang button in mobile * [bugfix] Popup overlay style update * [bugfix] NavBar click event * [Improvement] optimize build speed * [new feature] CellSwipe support async controll * [new feature] Uploader support inherit attrs
53 lines
1.3 KiB
Markdown
53 lines
1.3 KiB
Markdown
## Uploader 图片上传
|
|
|
|
### 使用指南
|
|
``` javascript
|
|
import { Uploader } from 'vant';
|
|
|
|
Vue.component(Uploader.name, Uploader);
|
|
```
|
|
|
|
### 代码演示
|
|
|
|
#### 基础用法
|
|
|
|
```html
|
|
<van-uploader :afterRead="logContent">
|
|
<van-icon name="photograph" />
|
|
</van-uploader>
|
|
```
|
|
|
|
```javascript
|
|
export default {
|
|
methods: {
|
|
logContent(file) {
|
|
console.log(file)
|
|
}
|
|
}
|
|
};
|
|
```
|
|
|
|
#### 设置 Input 属性
|
|
可以直接在 Uploader 上设置 accpet 等原生属性,input 会自动继承该属性
|
|
|
|
```html
|
|
<van-uploader :afterRead="logContent" accept="image/gif, image/jpeg">
|
|
<van-icon name="photograph" />
|
|
</van-uploader>
|
|
```
|
|
|
|
### API
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
|-----------|-----------|-----------|-------------|-------------|
|
|
| resultType | 读取文件的方式,以base64的方式读取;以文本的方式读取 | `String` | `dataUrl` | `text` |
|
|
| disable | 是否禁用上传,在图片上传期间设置为true,禁止用户点击此组件上传图片 | `Boolean` | `false` | - |
|
|
| beforeRead | 读文件之前的钩子,参数为选择的文件,若返回 false 则停止读取文件 | `Function` | - | - |
|
|
| afterRead | 文件读完之后回调此函数,参数为 { file:'选择的文件',content:'读的内容' } | `Function` | - | - |
|
|
|
|
### Slot
|
|
|
|
| name | 描述 |
|
|
|-----------|-----------|
|
|
| - | 自定义上传显示图标 |
|