diff --git a/packages/button/en-US.md b/packages/button/en-US.md index 3d0950201..d877d5e2e 100644 --- a/packages/button/en-US.md +++ b/packages/button/en-US.md @@ -63,7 +63,7 @@ Vue.use(Button); | type | Can be set to `primary` `info` `warning` `danger` | `String` | `default` | | size | Can be set to `large` `small` `mini` | `String` | `normal` | | text | Text | `String` | - | -| tag | Tag | `String` | `button` | +| tag | HTML Tag | `String` | `button` | | native-type | Native Type Attribute | `String` | `''` | | plain | Whether to be plain button | `Boolean` | `false` | | block | Whether to set display block | `Boolean` | `false` | diff --git a/packages/button/index.tsx b/packages/button/index.tsx index c1b8e0a4e..d9ccd4c34 100644 --- a/packages/button/index.tsx +++ b/packages/button/index.tsx @@ -8,7 +8,7 @@ import { CreateElement, RenderContext } from 'vue/types'; import { DefaultSlots } from '../utils/use/sfc'; export type ButtonProps = RouteProps & { - tag: string; + tag: keyof HTMLElementTagNameMap; type: string; size: string; text?: string; diff --git a/packages/goods-action-mini-btn/index.tsx b/packages/goods-action-mini-btn/index.tsx index 830ecedfb..f5904ba94 100644 --- a/packages/goods-action-mini-btn/index.tsx +++ b/packages/goods-action-mini-btn/index.tsx @@ -31,6 +31,7 @@ function GoodsActionMiniBtn(
diff --git a/packages/goods-action/test/__snapshots__/demo.spec.js.snap b/packages/goods-action/test/__snapshots__/demo.spec.js.snap index 93811d108..bf5d774c2 100644 --- a/packages/goods-action/test/__snapshots__/demo.spec.js.snap +++ b/packages/goods-action/test/__snapshots__/demo.spec.js.snap @@ -4,21 +4,35 @@ exports[`renders demo correctly 1`] = `
-
- 客服
-
- 购物车
+
+
+ +
客服 +
+
+
+ +
购物车 +
-
- 客服
-
+
+
+ +
客服 +
+
+
5
-
购物车
-
- 店铺
+
购物车 +
+
+
+ +
店铺 +
diff --git a/packages/goods-action/test/__snapshots__/index.spec.js.snap b/packages/goods-action/test/__snapshots__/index.spec.js.snap index aad32d878..f0ea9fd75 100644 --- a/packages/goods-action/test/__snapshots__/index.spec.js.snap +++ b/packages/goods-action/test/__snapshots__/index.spec.js.snap @@ -3,6 +3,9 @@ exports[`BigBtn render default slot 1`] = ``; exports[`Mini render default slot 1`] = ` -
- Default Content
+
+
+ +
Default Content +
`; diff --git a/packages/icon/en-US.md b/packages/icon/en-US.md index 2d6287a24..ccba887e1 100644 --- a/packages/icon/en-US.md +++ b/packages/icon/en-US.md @@ -62,7 +62,7 @@ import 'vant/lib/icon/local.css'; | color | Icon color | `String` | `inherit` | | size | Icon size | `String` | `inherit` | | class-prefix | ClassName prefix | `String` | `van-icon` | - +| tag | HTML Tag | `String` | `i` | ### Event diff --git a/packages/icon/index.tsx b/packages/icon/index.tsx index 34af173d8..d87b746ca 100644 --- a/packages/icon/index.tsx +++ b/packages/icon/index.tsx @@ -8,6 +8,7 @@ import { CreateElement, RenderContext } from 'vue/types'; import { DefaultSlots } from '../utils/use/sfc'; export type IconProps = { + tag: keyof HTMLElementTagNameMap; name: string; size?: string; color?: string; @@ -30,7 +31,7 @@ function Icon( const urlIcon = isSrc(props.name); return ( - } - + ); } @@ -53,6 +54,10 @@ Icon.props = { size: String, color: String, info: [String, Number], + tag: { + type: String, + default: 'i' + }, classPrefix: { type: String, default: 'van-icon' diff --git a/packages/icon/test/__snapshots__/index.spec.js.snap b/packages/icon/test/__snapshots__/index.spec.js.snap index e4fb87a58..cdd94e7ea 100644 --- a/packages/icon/test/__snapshots__/index.spec.js.snap +++ b/packages/icon/test/__snapshots__/index.spec.js.snap @@ -14,3 +14,9 @@ exports[`render icon with url name 1`] = ` `; + +exports[`tag prop 1`] = ` +
+ +
+`; diff --git a/packages/icon/test/index.spec.js b/packages/icon/test/index.spec.js index c6c967e7a..70e587753 100644 --- a/packages/icon/test/index.spec.js +++ b/packages/icon/test/index.spec.js @@ -27,3 +27,12 @@ test('render icon default slot', () => { }); expect(wrapper).toMatchSnapshot(); }); + +test('tag prop', () => { + const wrapper = mount(Icon, { + propsData: { + tag: 'div' + } + }); + expect(wrapper).toMatchSnapshot(); +}); diff --git a/packages/icon/zh-CN.md b/packages/icon/zh-CN.md index bb1b39168..20e20021a 100644 --- a/packages/icon/zh-CN.md +++ b/packages/icon/zh-CN.md @@ -65,10 +65,10 @@ import 'vant/lib/icon/local.css'; | color | 图标颜色 | `String` | `inherit` | 1.1.3 | | size | 图标大小,如 `20px` `2em` | `String` | `inherit` | 1.1.15 | | class-prefix | 类名前缀 | `String` | `van-icon` | 1.2.1 | +| tag | HTML 标签 | `String` | `i` | 1.6.10 | ### Event | 事件名 | 说明 | 参数 | |------|------|------| | click | 点击图标时触发 | - | -