mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-23 09:52:57 +08:00
feat(Uploader): add deletable prop (#4925)
This commit is contained in:
parent
fbb34a0f90
commit
0d3eec10b5
@ -118,6 +118,7 @@ export default {
|
|||||||
| preview-full-image | Whethe to show full screen image preview when click image | *boolean* | `true` | - |
|
| preview-full-image | Whethe to show full screen image preview when click image | *boolean* | `true` | - |
|
||||||
| multiple | Whether to enable multiple selection pictures | *boolean* | `false` | - |
|
| multiple | Whether to enable multiple selection pictures | *boolean* | `false` | - |
|
||||||
| disabled | Whether to disabled the upload | *boolean* | `false` | - |
|
| disabled | Whether to disabled the upload | *boolean* | `false` | - |
|
||||||
|
| deletable | Whether to show delete icon | *boolean* | `true` | 2.2.12 |
|
||||||
| capture | Capture,can be set to `camera` | *string* | - | - |
|
| capture | Capture,can be set to `camera` | *string* | - | - |
|
||||||
| after-read | Hook after reading the file | *Function* | - | - |
|
| after-read | Hook after reading the file | *Function* | - | - |
|
||||||
| before-read | Hook before reading the file, return false to stop reading the file, can return Promise | *Function* | - | - |
|
| before-read | Hook before reading the file, return false to stop reading the file, can return Promise | *Function* | - | - |
|
||||||
|
@ -134,6 +134,7 @@ export default {
|
|||||||
| preview-full-image | 是否在点击预览图后展示全屏图片预览 | *boolean* | `true` | 2.1.5 |
|
| preview-full-image | 是否在点击预览图后展示全屏图片预览 | *boolean* | `true` | 2.1.5 |
|
||||||
| multiple | 是否开启图片多选,部分安卓机型不支持 | *boolean* | `false` | - |
|
| multiple | 是否开启图片多选,部分安卓机型不支持 | *boolean* | `false` | - |
|
||||||
| disabled | 是否禁用文件上传 | *boolean* | `false` | - |
|
| disabled | 是否禁用文件上传 | *boolean* | `false` | - |
|
||||||
|
| deletable | 是否展示删除按钮 | *boolean* | `true` | 2.2.12 |
|
||||||
| capture | 图片选取模式,可选值为`camera`(直接调起摄像头) | *string* | - | - |
|
| capture | 图片选取模式,可选值为`camera`(直接调起摄像头) | *string* | - | - |
|
||||||
| after-read | 文件读取完成后的回调函数 | *Function* | - | - |
|
| after-read | 文件读取完成后的回调函数 | *Function* | - | - |
|
||||||
| before-read | 文件读取前的回调函数,返回`false`可终止文件读取,支持返回`Promise` | *Function* | - | - |
|
| before-read | 文件读取前的回调函数,返回`false`可终止文件读取,支持返回`Promise` | *Function* | - | - |
|
||||||
|
@ -40,6 +40,10 @@ export default createComponent({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: Number.MAX_VALUE
|
default: Number.MAX_VALUE
|
||||||
},
|
},
|
||||||
|
deletable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
previewImage: {
|
previewImage: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
@ -214,7 +218,7 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
genPreviewItem(item, index) {
|
genPreviewItem(item, index) {
|
||||||
const DeleteIcon = (
|
const DeleteIcon = this.deletable && (
|
||||||
<Icon
|
<Icon
|
||||||
name="clear"
|
name="clear"
|
||||||
class={bem('preview-delete')}
|
class={bem('preview-delete')}
|
||||||
|
@ -270,6 +270,19 @@ it('preview-size prop', async () => {
|
|||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('deletable prop', () => {
|
||||||
|
const wrapper = mount(Uploader, {
|
||||||
|
propsData: {
|
||||||
|
fileList: [{ url: IMAGE }]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.find('.van-uploader__preview-delete').element).toBeTruthy();
|
||||||
|
|
||||||
|
wrapper.setProps({ deletable: false });
|
||||||
|
expect(wrapper.find('.van-uploader__preview-delete').element).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
it('delete preview image', () => {
|
it('delete preview image', () => {
|
||||||
const wrapper = mount(Uploader, {
|
const wrapper = mount(Uploader, {
|
||||||
propsData: {
|
propsData: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user