mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-26 12:32:17 +08:00
feat(components): [image] progress
slot higher priority (#20353)
* feat(components): [image] `progress` slot higher priority * fix: update * chore: delete extra spaces --------- Co-authored-by: warmthsea <2586244885@qq.com>
This commit is contained in:
@ -65,12 +65,20 @@ image/manually-preview
|
|||||||
|
|
||||||
## Custom Toolbar ^(2.9.4)
|
## Custom Toolbar ^(2.9.4)
|
||||||
|
|
||||||
:::demo Custom toolbar content by `toolbar` slot, starting from version ^(2.9.7) , the slot has a new `setActiveItem` function, which can be switched according to the index.
|
:::demo Custom toolbar content by `toolbar` slot, starting from version ^(2.9.7), the slot has a new `setActiveItem` function, which can be switched according to the index.
|
||||||
|
|
||||||
image/custom-toolbar
|
image/custom-toolbar
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
## Custom progress ^(2.9.4)
|
||||||
|
|
||||||
|
:::demo By setting the `show-progress` prop to control whether to display progress when previewing an image. After version ^(2.9.8), the progress content will be displayed as long as the `progress` slot is used.
|
||||||
|
|
||||||
|
image/custom-progress
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
## Image API
|
## Image API
|
||||||
|
|
||||||
### Image Attributes
|
### Image Attributes
|
||||||
@ -95,7 +103,7 @@ image/custom-toolbar
|
|||||||
| zoom-rate | the zoom rate of the image viewer zoom event. | ^[number] | 1.2 |
|
| zoom-rate | the zoom rate of the image viewer zoom event. | ^[number] | 1.2 |
|
||||||
| min-scale ^(2.4.0) | the min scale of the image viewer zoom event. | ^[number] | 0.2 |
|
| min-scale ^(2.4.0) | the min scale of the image viewer zoom event. | ^[number] | 0.2 |
|
||||||
| max-scale ^(2.4.0) | the max scale of the image viewer zoom event. | ^[number] | 7 |
|
| max-scale ^(2.4.0) | the max scale of the image viewer zoom event. | ^[number] | 7 |
|
||||||
| show-progress ^(2.9.4) | whether to display the preview image progress content | ^[boolean] | false |
|
| show-progress ^(2.9.4) | whether to display the preview image progress content. | ^[boolean] | false |
|
||||||
|
|
||||||
### Image Events
|
### Image Events
|
||||||
|
|
||||||
@ -109,13 +117,13 @@ image/custom-toolbar
|
|||||||
|
|
||||||
### Image Slots
|
### Image Slots
|
||||||
|
|
||||||
| Name | Description | Type |
|
| Name | Description | Type |
|
||||||
| ----------------- | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ----------------- | ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| placeholder | custom placeholder content when image hasn't loaded yet. | - |
|
| placeholder | custom placeholder content when image hasn't loaded yet. | - |
|
||||||
| error | custom image load failed content. | - |
|
| error | custom image load failed content. | - |
|
||||||
| viewer | custom content when image preview. | - |
|
| viewer | custom content when image preview. | - |
|
||||||
| progress ^(2.9.4) | custom progress content when image preview. | ^[object]`{ activeIndex: number, total: number }` |
|
| progress ^(2.9.4) | custom progress content when image preview. (Priority is higher than `show-progress` prop) | ^[object]`{ activeIndex: number, total: number }` |
|
||||||
| toolbar ^(2.9.4) | custom toolbar content when image preview. | ^[object]`{actions: (action: ImageViewerAction, options?: ImageViewerActionOptions ) => void, prev: ()=> void, next: () => void,reset: () => void, activeIndex: number }, setActiveItem: (index: number) => void` |
|
| toolbar ^(2.9.4) | custom toolbar content when image preview. | ^[object]`{actions: (action: ImageViewerAction, options?: ImageViewerActionOptions ) => void, prev: ()=> void, next: () => void,reset: () => void, activeIndex: number }, setActiveItem: (index: number) => void` |
|
||||||
|
|
||||||
### Image Exposes
|
### Image Exposes
|
||||||
|
|
||||||
|
28
docs/examples/image/custom-progress.vue
Normal file
28
docs/examples/image/custom-progress.vue
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<template>
|
||||||
|
<div class="demo-image__custom-toolbar">
|
||||||
|
<el-image
|
||||||
|
style="width: 100px; height: 100px"
|
||||||
|
:src="url"
|
||||||
|
:preview-src-list="srcList"
|
||||||
|
fit="cover"
|
||||||
|
>
|
||||||
|
<template #progress="{ activeIndex, total }">
|
||||||
|
<span>{{ activeIndex + 1 + '-' + total }}</span>
|
||||||
|
</template>
|
||||||
|
</el-image>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
const url =
|
||||||
|
'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg'
|
||||||
|
const srcList = [
|
||||||
|
'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg',
|
||||||
|
'https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg',
|
||||||
|
'https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg',
|
||||||
|
'https://fuss10.elemecdn.com/9/bb/e27858e973f5d7d3904835f46abbdjpeg.jpeg',
|
||||||
|
'https://fuss10.elemecdn.com/d/e6/c4d93a3805b3ce3f323f7974e6f78jpeg.jpeg',
|
||||||
|
'https://fuss10.elemecdn.com/3/28/bbf893f792f03a54408b3b7a7ebf0jpeg.jpeg',
|
||||||
|
'https://fuss10.elemecdn.com/2/11/6535bcfb26e4c79b48ddde44f4b6fjpeg.jpeg',
|
||||||
|
]
|
||||||
|
</script>
|
@ -7,9 +7,6 @@
|
|||||||
fit="cover"
|
fit="cover"
|
||||||
show-progress
|
show-progress
|
||||||
>
|
>
|
||||||
<template #progress="{ activeIndex, total }">
|
|
||||||
<span>{{ activeIndex + 1 + '-' + total }}</span>
|
|
||||||
</template>
|
|
||||||
<template
|
<template
|
||||||
#toolbar="{ actions, prev, next, reset, activeIndex, setActiveItem }"
|
#toolbar="{ actions, prev, next, reset, activeIndex, setActiveItem }"
|
||||||
>
|
>
|
||||||
|
@ -37,7 +37,10 @@
|
|||||||
</el-icon>
|
</el-icon>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<div v-if="showProgress" :class="[ns.e('btn'), ns.e('progress')]">
|
<div
|
||||||
|
v-if="$slots.progress || showProgress"
|
||||||
|
:class="[ns.e('btn'), ns.e('progress')]"
|
||||||
|
>
|
||||||
<slot
|
<slot
|
||||||
name="progress"
|
name="progress"
|
||||||
:active-index="activeIndex"
|
:active-index="activeIndex"
|
||||||
|
Reference in New Issue
Block a user