File tree 5 files changed +16
-0
lines changed
5 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ name | type | default | description | required
8
8
-- | -- | -- | -- | --
9
9
alt | String | - | \- | N
10
10
error | String / Slot / Function | - | Typescript:` string \| TNode ` 。[ see more ts definition] ( https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts ) | N
11
+ fallback | String | - | display ` fallback ` image on ` src ` loading failed. you can also use ` error ` to define more complex error content | N
11
12
fit | String | fill | options: contain/cover/fill/none/scale-down | N
12
13
lazy | Boolean | false | \- | N
13
14
loading | String / Slot / Function | - | Typescript:` string \| TNode ` 。[ see more ts definition] ( https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts ) | N
Original file line number Diff line number Diff line change 8
8
-- | -- | -- | -- | --
9
9
alt | String | - | 图片描述 | N
10
10
error | String / Slot / Function | - | 自定义图片加载失败状态下的显示内容。TS 类型:` string \| TNode ` 。[ 通用类型定义] ( https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts ) | N
11
+ fallback | String | - | 图片加载失败时,显示当前链接设置的图片地址。如果要使用组件图标或完全自定义加载失败时显示的内容,请更为使用 ` error ` | N
11
12
fit | String | fill | 图片填充模式。可选项:contain/cover/fill/none/scale-down | N
12
13
lazy | Boolean | false | 是否开启图片懒加载 | N
13
14
loading | String / Slot / Function | - | 自定义加载中状态的图片内容,如:“加载中”。TS 类型:` string \| TNode ` 。[ 通用类型定义] ( https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts ) | N
Original file line number Diff line number Diff line change @@ -66,6 +66,10 @@ export default defineComponent({
66
66
props . onError ?.( { e } ) ;
67
67
isLoading . value = false ;
68
68
isError . value = true ;
69
+ if ( props . fallback ) {
70
+ realSrc . value = props . fallback ;
71
+ isError . value = false ;
72
+ }
69
73
} ;
70
74
71
75
const maskContent = computed ( ( ) => {
Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ export default {
17
17
error : {
18
18
type : [ String , Function ] as PropType < TdImageProps [ 'error' ] > ,
19
19
} ,
20
+ /** 图片加载失败时,显示当前链接设置的图片地址。如果要使用组件图标或完全自定义加载失败时显示的内容,请更为使用 `error` */
21
+ fallback : {
22
+ type : String ,
23
+ default : '' ,
24
+ } ,
20
25
/** 图片填充模式 */
21
26
fit : {
22
27
type : String as PropType < TdImageProps [ 'fit' ] > ,
Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ export interface TdImageProps {
16
16
* 自定义图片加载失败状态下的显示内容
17
17
*/
18
18
error ?: string | TNode ;
19
+ /**
20
+ * 图片加载失败时,显示当前链接设置的图片地址。如果要使用组件图标或完全自定义加载失败时显示的内容,请更为使用 `error`
21
+ * @default ''
22
+ */
23
+ fallback ?: string ;
19
24
/**
20
25
* 图片填充模式
21
26
* @default fill
You can’t perform that action at this time.
0 commit comments