diff --git a/docs/demos/views/icon.vue b/docs/demos/views/icon.vue index ae289f111..0e24f3c81 100644 --- a/docs/demos/views/icon.vue +++ b/docs/demos/views/icon.vue @@ -2,7 +2,7 @@ - + {{ icon }} diff --git a/docs/markdown/en-US/icon.md b/docs/markdown/en-US/icon.md index 2adf19715..51999d7df 100644 --- a/docs/markdown/en-US/icon.md +++ b/docs/markdown/en-US/icon.md @@ -28,3 +28,4 @@ import 'vant/lib/vant-css/icon-local.css'; | Attribute | Description | Type | Default | Accepted Values | |-----------|-----------|-----------|-------------|-------------| | name | Icon name | `String` | `''` | - | +| info | Info message | `String` | `''` | - | diff --git a/docs/markdown/zh-CN/icon.md b/docs/markdown/zh-CN/icon.md index 9bad60002..d47fd0c0c 100644 --- a/docs/markdown/zh-CN/icon.md +++ b/docs/markdown/zh-CN/icon.md @@ -28,4 +28,5 @@ import 'vant/lib/vant-css/icon-local.css'; | 参数 | 说明 | 类型 | 默认值 | 可选值 | |-----------|-----------|-----------|-------------|-------------| -| name | icon名称 | `String` | `''` | - | +| name | 图标名称 | `String` | `''` | - | +| info | 图标右上角文字提示 | `String` | `''` | - | diff --git a/packages/icon/index.vue b/packages/icon/index.vue index 43e7f725a..7ee6219d8 100644 --- a/packages/icon/index.vue +++ b/packages/icon/index.vue @@ -1,6 +1,7 @@ @@ -11,7 +12,8 @@ export default { install, name: 'van-icon', props: { - name: String + name: String, + info: String } }; diff --git a/packages/tabbar-item/index.vue b/packages/tabbar-item/index.vue index f5c212e67..a997ade7a 100644 --- a/packages/tabbar-item/index.vue +++ b/packages/tabbar-item/index.vue @@ -4,7 +4,7 @@ -
{{ info }}
+
{{ info }}
@@ -42,8 +42,9 @@ export default create({ }, methods: { - onClick() { + onClick(event) { this.$parent.onChange(this.$parent.items.indexOf(this)); + this.$emit('click', event); this.routerLink(); } } diff --git a/packages/vant-css/scripts/icon-template.css b/packages/vant-css/scripts/icon-template.css index 80008e269..6e1a9542c 100644 --- a/packages/vant-css/scripts/icon-template.css +++ b/packages/vant-css/scripts/icon-template.css @@ -1,3 +1,5 @@ +@import './common/var.css'; + @font-face { font-style: normal; font-weight: normal; @@ -11,6 +13,23 @@ font-size: inherit; text-rendering: auto; + &__info { + color: #fff; + left: 50%; + top: -.5em; + font-size: .5em; + margin-left: .8em; + padding: 0 .3em; + text-align: center; + min-width: 1.2em; + line-height: 1.2; + position: absolute; + border-radius: .6em; + box-sizing: border-box; + background-color: $red; + font-family: PingFang SC, Helvetica Neue, Arial, sans-serif; + } + &:before { display: inline-block; } diff --git a/packages/vant-css/src/icon.css b/packages/vant-css/src/icon.css index b15353fde..5681d3dfd 100644 --- a/packages/vant-css/src/icon.css +++ b/packages/vant-css/src/icon.css @@ -1,3 +1,5 @@ +@import './common/var.css'; + @font-face { font-style: normal; font-weight: normal; @@ -6,11 +8,29 @@ } .van-icon { + position: relative; display: inline-block; font: normal normal normal 14px/1 "vant-icon"; font-size: inherit; text-rendering: auto; + &__info { + color: #fff; + left: 50%; + top: -.5em; + font-size: .5em; + margin-left: .8em; + padding: 0 .3em; + text-align: center; + min-width: 1.2em; + line-height: 1.2; + position: absolute; + border-radius: .6em; + box-sizing: border-box; + background-color: $red; + font-family: PingFang SC, Helvetica Neue, Arial, sans-serif; + } + &:before { display: inline-block; } diff --git a/packages/vant-css/src/tabbar.css b/packages/vant-css/src/tabbar.css index f8c0a952f..4a2c82f33 100644 --- a/packages/vant-css/src/tabbar.css +++ b/packages/vant-css/src/tabbar.css @@ -49,22 +49,6 @@ } } - &__info { - color: #fff; - top: -5px; - right: -100%; - font-size: 12px; - transform: scale(.8); - box-sizing: border-box; - padding: 0 3px; - text-align: center; - min-width: 18px; - line-height: 18px; - border-radius: 9px; - background-color: $red; - position: absolute; - } - &--active { color: $blue; }