File tree 6 files changed +34
-16
lines changed
6 files changed +34
-16
lines changed Original file line number Diff line number Diff line change 1
1
:: BASE_DOC ::
2
2
3
3
## API
4
+
4
5
### Image Props
5
6
6
7
name | type | default | description | required
7
8
-- | -- | -- | -- | --
9
+ t-id | String | - | ` 1.2.10 ` . image tag id | N
8
10
error | String / Slot | 'default' | \- | N
9
11
external-classes | Array | - | ` ['t-class', 't-class-load'] ` | N
10
12
height | String / Number | - | \- | N
@@ -24,12 +26,12 @@ name | params | description
24
26
error | \- | \-
25
27
load | \- | \-
26
28
27
-
28
29
### CSS Variables
30
+
29
31
The component provides the following CSS variables, which can be used to customize styles.
30
- Name | Default Value | Description
32
+ Name | Default Value | Description
31
33
-- | -- | --
32
- --td-image-color | @font-gray-3 | -
33
- --td-image-loading-bg-color | @bg-color-secondarycontainer | -
34
- --td-image-loading-color | @font-gray-3 | -
35
- --td-image-round-radius | @radius-default | -
34
+ --td-image-color | @font-gray-3 | -
35
+ --td-image-loading-bg-color | @bg-color-secondarycontainer | -
36
+ --td-image-loading-color | @font-gray-3 | -
37
+ --td-image-round-radius | @radius-default | -
Original file line number Diff line number Diff line change @@ -39,12 +39,13 @@ isComponent: true
39
39
</p >
40
40
</details >
41
41
42
-
43
42
## API
43
+
44
44
### Image Props
45
45
46
46
名称 | 类型 | 默认值 | 说明 | 必传
47
47
-- | -- | -- | -- | --
48
+ t-id | String | - | ` 1.2.10 ` 。图片标签id | N
48
49
error | String / Slot | 'default' | 加载失败时显示的内容。值为 ` default ` 则表示使用默认加载失败风格;值为空或者 ` slot ` 表示使用插槽渲染,插槽名称为 ` error ` ;值为其他则表示普通文本内容,如“加载失败” | N
49
50
height | String / Number | - | 高度,默认单位为` px ` | N
50
51
lazy | Boolean | false | 是否开启图片懒加载 | N
@@ -64,16 +65,18 @@ error | \- | 图片加载失败时触发
64
65
load | \- | 图片加载完成时触发
65
66
66
67
### Image 外部样式类
68
+
67
69
类名 | 说明
68
- -- | --
70
+ -- | --
69
71
t-class | 根节点样式类
70
72
t-class-load | 加载样式类
71
73
72
74
### CSS 变量
75
+
73
76
组件提供了下列 CSS 变量,可用于自定义样式。
74
- 名称 | 默认值 | 描述
77
+ 名称 | 默认值 | 描述
75
78
-- | -- | --
76
- --td-image-color | @font-gray-3 | -
77
- --td-image-loading-bg-color | @bg-color-secondarycontainer | -
78
- --td-image-loading-color | @font-gray-3 | -
79
- --td-image-round-radius | @radius-default | -
79
+ --td-image-color | @font-gray-3 | -
80
+ --td-image-loading-bg-color | @bg-color-secondarycontainer | -
81
+ --td-image-loading-color | @font-gray-3 | -
82
+ --td-image-round-radius | @radius-default | -
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ export default class Image extends SuperComponent {
39
39
onLoaded ( e : any ) {
40
40
const sdkVersion = wx . getSystemInfoSync ( ) . SDKVersion ;
41
41
const versionArray = sdkVersion . split ( '.' ) . map ( ( v ) => parseInt ( v , 10 ) ) ;
42
- const { mode } = this . properties ;
42
+ const { mode, tId } = this . properties ;
43
43
const isInCompatible =
44
44
versionArray [ 0 ] < 2 ||
45
45
( versionArray [ 0 ] === 2 && versionArray [ 1 ] < 10 ) ||
@@ -48,7 +48,7 @@ export default class Image extends SuperComponent {
48
48
if ( mode === 'heightFix' && isInCompatible ) {
49
49
// 实现heightFix模式,保持高度和宽高比,设置对应的宽度
50
50
const { height : picHeight , width : picWidth } = e . detail ;
51
- getRect ( this , '# image') . then ( ( rect ) => {
51
+ getRect ( this , `# ${ tId ?? ' image'} ` ) . then ( ( rect ) => {
52
52
const { height } = rect ;
53
53
const resultWidth = ( ( height / picHeight ) * picWidth ) . toFixed ( 2 ) ;
54
54
this . setData ( { innerStyle : `height: ${ addUnit ( height ) } ; width: ${ resultWidth } px;` } ) ;
Original file line number Diff line number Diff line change 36
36
</view>
37
37
<!-- 图片 -->
38
38
<image
39
- id="image"
39
+ id="{{tId||' image'}} "
40
40
hidden="{{isLoading || isFailed}}"
41
41
class="class {{prefix}}-class {{classPrefix}} {{classPrefix}}--shape-{{shape}}"
42
42
src="{{src}}"
Original file line number Diff line number Diff line change 6
6
7
7
import { TdImageProps } from './type' ;
8
8
const props : TdImageProps = {
9
+ /** id,默认为null */
10
+ tId : {
11
+ type : String ,
12
+ value : null ,
13
+ } ,
9
14
/** 加载失败时显示的内容。值为 `default` 则表示使用默认加载失败风格;值为空或者 `slot` 表示使用插槽渲染,插槽名称为 `error`;值为其他则表示普通文本内容,如“加载失败” */
10
15
error : {
11
16
type : String ,
Original file line number Diff line number Diff line change 5
5
* */
6
6
7
7
export interface TdImageProps {
8
+ /**
9
+ * 自定义组件id
10
+ * @default null
11
+ */
12
+ tId ?: {
13
+ type : StringConstructor ;
14
+ value ?: string ;
15
+ } ;
8
16
/**
9
17
* 自定义组件样式
10
18
* @default ''
You can’t perform that action at this time.
0 commit comments