File tree Expand file tree Collapse file tree 5 files changed +23
-6
lines changed Expand file tree Collapse file tree 5 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ export default {
52
52
| Attribute | Description | Type | Default |
53
53
| ------| ------| ------| ------|
54
54
| items | Required datasets for the component | ` Item[] ` | ` [] ` |
55
- | height | Height (px) | ` number ` | ` 300 ` |
55
+ | height | Height | `string | number` | ` 300 ` |
56
56
| main-Active-index | The index of selected parent node | ` number ` | ` 0 ` |
57
57
| active-id | Id of selected item | `string | number` | ` 0 ` |
58
58
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ export default {
52
52
| 参数 | 说明 | 类型 | 默认值 | 版本 |
53
53
| ------| ------| ------| ------| ------|
54
54
| items | 分类显示所需的数据 | ` Item[] ` | ` [] ` | - |
55
- | height | 高度,单位为 px | ` number ` | ` 300 ` | - |
55
+ | height | 高度,默认单位为 px | `string | number` | ` 300 ` | - |
56
56
| main-active-index | 左侧导航高亮的索引 | ` number ` | ` 0 ` | - |
57
57
| active-id | 右侧选择项,高亮的数据id | `string | number` | ` 0 ` | - |
58
58
Original file line number Diff line number Diff line change 1
- import { createNamespace } from '../utils' ;
1
+ import { createNamespace , addUnit } from '../utils' ;
2
2
import { emit , inherit } from '../utils/functional' ;
3
3
import Icon from '../icon' ;
4
4
@@ -19,7 +19,7 @@ export type TreeSelectChildren = {
19
19
} ;
20
20
21
21
export type TreeSelectProps = {
22
- height : number ;
22
+ height : number | string ;
23
23
items : TreeSelectItem [ ] ;
24
24
activeId : number | string ;
25
25
mainActiveIndex : number ;
@@ -98,7 +98,7 @@ function TreeSelect(
98
98
}
99
99
100
100
return (
101
- < div class = { bem ( ) } style = { { height : ` ${ height } px` } } { ...inherit ( ctx ) } >
101
+ < div class = { bem ( ) } style = { { height : addUnit ( height ) } } { ...inherit ( ctx ) } >
102
102
< div class = { bem ( 'nav' ) } > { Nav } </ div >
103
103
< div class = { bem ( 'content' ) } > { Content ( ) } </ div >
104
104
</ div >
@@ -111,7 +111,7 @@ TreeSelect.props = {
111
111
default : ( ) => [ ]
112
112
} ,
113
113
height : {
114
- type : Number ,
114
+ type : [ Number , String ] ,
115
115
default : 300
116
116
} ,
117
117
activeId : {
Original file line number Diff line number Diff line change @@ -15,3 +15,10 @@ exports[`empty list 1`] = `
15
15
<div class = " van-tree-select__content" ></div >
16
16
</div >
17
17
` ;
18
+
19
+ exports [` height prop 1` ] = `
20
+ <div class = " van-tree-select" style = " height: 100vh;" >
21
+ <div class = " van-tree-select__nav" ></div >
22
+ <div class = " van-tree-select__content" ></div >
23
+ </div >
24
+ ` ;
Original file line number Diff line number Diff line change @@ -141,3 +141,13 @@ test('content slot', () => {
141
141
142
142
expect ( wrapper ) . toMatchSnapshot ( ) ;
143
143
} ) ;
144
+
145
+ test ( 'height prop' , ( ) => {
146
+ const wrapper = mount ( TreeSelect , {
147
+ propsData : {
148
+ height : '100vh'
149
+ }
150
+ } ) ;
151
+
152
+ expect ( wrapper ) . toMatchSnapshot ( ) ;
153
+ } ) ;
You can’t perform that action at this time.
0 commit comments