mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
fix(components): [image, image-viewer] Add crossorigin property (#15406)
Co-authored-by: Xc <124118265@qq.com>
This commit is contained in:
parent
2664188c21
commit
4a3318f7b1
@ -69,6 +69,7 @@ image/image-preview
|
||||
| scroll-container | the container to add scroll listener when using lazy load. By default, the container to add scroll listener when using lazy load. | ^[string] / ^[object]`HTMLElement` | — |
|
||||
| alt | native attribute `alt`. | ^[string] | — |
|
||||
| referrerpolicy | native attribute [referrerPolicy](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/referrerPolicy). | ^[string] | — |
|
||||
| crossorigin | native attribute [crossorigin](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin). | ^[enum]`'' \| 'anonymous' \| 'use-credentials'` | 'anonymous' | — |
|
||||
| preview-src-list | allow big image preview. | ^[object]`string[]` | [] |
|
||||
| z-index | set image preview z-index. | ^[number] | — |
|
||||
| initial-index | initial preview image index, less than the length of `url-list`. | ^[number] | 0 |
|
||||
|
@ -78,6 +78,13 @@ export const imageViewerProps = buildProps({
|
||||
type: Number,
|
||||
default: 7,
|
||||
},
|
||||
/**
|
||||
* @description set HTML attribute: crossorigin.
|
||||
*/
|
||||
crossorigin: {
|
||||
type: definePropType<'anonymous' | 'use-credentials' | ''>(String),
|
||||
default: 'anonymous',
|
||||
},
|
||||
} as const)
|
||||
export type ImageViewerProps = ExtractPropTypes<typeof imageViewerProps>
|
||||
|
||||
|
@ -55,6 +55,7 @@
|
||||
:src="url"
|
||||
:style="imgStyle"
|
||||
:class="ns.e('img')"
|
||||
:crossorigin="crossorigin"
|
||||
@load="handleImgLoad"
|
||||
@error="handleImgError"
|
||||
@mousedown="handleMouseDown"
|
||||
@ -126,6 +127,7 @@ const imgRefs = ref<HTMLImageElement[]>([])
|
||||
const scopeEventListener = effectScope()
|
||||
|
||||
const loading = ref(true)
|
||||
const crossorigin = ref<string>(props.crossorigin)
|
||||
const activeIndex = ref(props.initialIndex)
|
||||
const mode = shallowRef<ImageViewerMode>(modes.CONTAIN)
|
||||
const transform = ref({
|
||||
|
@ -103,6 +103,13 @@ export const imageProps = buildProps({
|
||||
type: Number,
|
||||
default: 7,
|
||||
},
|
||||
/**
|
||||
* @description set HTML attribute: crossorigin.
|
||||
*/
|
||||
crossorigin: {
|
||||
type: definePropType<'anonymous' | 'use-credentials' | ''>(String),
|
||||
default: 'anonymous',
|
||||
},
|
||||
} as const)
|
||||
export type ImageProps = ExtractPropTypes<typeof imageProps>
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
:loading="loading"
|
||||
:style="imageStyle"
|
||||
:class="imageKls"
|
||||
:crossorigin="crossorigin"
|
||||
@click="clickHandler"
|
||||
@load="handleLoad"
|
||||
@error="handleError"
|
||||
@ -84,6 +85,7 @@ const rawAttrs = useRawAttrs()
|
||||
const attrs = useAttrs()
|
||||
|
||||
const imageSrc = ref<string | undefined>()
|
||||
const crossorigin = ref<string>(props.crossorigin)
|
||||
const hasLoadError = ref(false)
|
||||
const isLoading = ref(true)
|
||||
const showViewer = ref(false)
|
||||
|
Loading…
Reference in New Issue
Block a user