mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-05-21 13:59:15 +08:00
feat(Icon): size prop support number type (#1978)
This commit is contained in:
parent
a37e0b9fa5
commit
fa633f42d7
@ -39,7 +39,7 @@
|
|||||||
| name | 图标名称或图片链接 | *string* | - | - |
|
| name | 图标名称或图片链接 | *string* | - | - |
|
||||||
| info | 图标右上角文字提示 | *string \| number* | - | - |
|
| info | 图标右上角文字提示 | *string \| number* | - | - |
|
||||||
| color | 图标颜色 | *string* | `inherit` | - |
|
| color | 图标颜色 | *string* | `inherit` | - |
|
||||||
| size | 图标大小,如 `20px`,`2em` | *string* | `inherit` | - |
|
| size | 图标大小,如 `20px`,`2em`,默认单位为`px` | *string \| number* | `inherit` | - |
|
||||||
| custom-style | 自定义样式 | *string* | - | - |
|
| custom-style | 自定义样式 | *string* | - | - |
|
||||||
| class-prefix | 类名前缀 | *string* | `van-icon` | - |
|
| class-prefix | 类名前缀 | *string* | `van-icon` | - |
|
||||||
|
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
import { VantComponent } from '../common/component';
|
import { VantComponent } from '../common/component';
|
||||||
|
import { addUnit } from '../common/utils';
|
||||||
|
|
||||||
VantComponent({
|
VantComponent({
|
||||||
props: {
|
props: {
|
||||||
info: null,
|
info: null,
|
||||||
size: String,
|
size: {
|
||||||
|
type: null,
|
||||||
|
observer: 'setSizeWithUnit'
|
||||||
|
},
|
||||||
color: String,
|
color: String,
|
||||||
customStyle: String,
|
customStyle: String,
|
||||||
classPrefix: {
|
classPrefix: {
|
||||||
@ -20,9 +24,19 @@ VantComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
data: {
|
||||||
|
sizeWithUnit: null,
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onClick() {
|
onClick() {
|
||||||
this.$emit('click');
|
this.$emit('click');
|
||||||
|
},
|
||||||
|
|
||||||
|
setSizeWithUnit(size: string | number): void {
|
||||||
|
this.set({
|
||||||
|
sizeWithUnit: addUnit(size)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<view
|
<view
|
||||||
class="custom-class {{ classPrefix }} {{ isImageName ? 'van-icon--image' : classPrefix + '-' + name }}"
|
class="custom-class {{ classPrefix }} {{ isImageName ? 'van-icon--image' : classPrefix + '-' + name }}"
|
||||||
style="{{ color ? 'color: ' + color + ';' : '' }}{{ size ? 'font-size: ' + size + ';' : '' }}{{ customStyle }}"
|
style="{{ color ? 'color: ' + color + ';' : '' }}{{ size ? 'font-size: ' + sizeWithUnit + ';' : '' }}{{ customStyle }}"
|
||||||
bind:tap="onClick"
|
bind:tap="onClick"
|
||||||
>
|
>
|
||||||
<van-info
|
<van-info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user