3636</template >
3737
3838<script lang="ts" setup>
39- import { computed , nextTick , onMounted , ref , watch } from ' vue'
39+ import {
40+ computed ,
41+ nextTick ,
42+ onMounted ,
43+ ref ,
44+ useAttrs as useRawAttrs ,
45+ watch ,
46+ } from ' vue'
4047import {
4148 isBoolean ,
4249 isClient ,
@@ -62,6 +69,7 @@ import type { CSSProperties, StyleValue } from 'vue'
6269
6370defineOptions ({
6471 name: ' ElImage' ,
72+ inheritAttrs: false ,
6573})
6674
6775const props = defineProps (imageProps )
@@ -82,8 +90,9 @@ useDeprecated(
8290
8391const { t } = useLocale ()
8492const ns = useNamespace (' image' )
85-
93+ const rawAttrs = useRawAttrs ()
8694const attrs = useAttrs ()
95+
8796const hasLoadError = ref (false )
8897const loading = ref (true )
8998const imgWidth = ref (0 )
@@ -95,7 +104,7 @@ const _scrollContainer = ref<HTMLElement | Window>()
95104let stopScrollListener: () => void
96105let stopWheelListener: () => void
97106
98- const containerStyle = computed (() => attrs . value .style as StyleValue )
107+ const containerStyle = computed (() => rawAttrs .style as StyleValue )
99108
100109const imageStyle = computed <CSSProperties >(() => {
101110 const { fit } = props
@@ -149,7 +158,7 @@ const loadImage = () => {
149158
150159 // bind html attrs
151160 // so it can behave consistently
152- Object .entries (attrs . value ).forEach (([key , value ]) => {
161+ Object .entries (rawAttrs ).forEach (([key , value ]) => {
153162 // avoid onload to be overwritten
154163 if (key .toLowerCase () === ' onload' ) return
155164 img .setAttribute (key , value as string )
0 commit comments