fix(Button): icon-prefix prop not work (#5947)

This commit is contained in:
neverland 2020-03-30 17:16:07 +08:00 committed by GitHub
parent 6ce940d0db
commit da8212be7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 4 deletions

View File

@ -106,7 +106,7 @@ Vue.use(Button);
| text | Text | *string* | - |
| color `v2.1.8` | Color, support linear-gradient | *string* | - |
| icon | Left Icon | *string* | - |
| icon-prefix `v2.5.3` | Icon className prefix | *string* | `van-icon` |
| icon-prefix `v2.6.0` | Icon className prefix | *string* | `van-icon` |
| tag | HTML Tag | *string* | `button` |
| native-type | Native Type Attribute | *string* | `''` |
| plain | Whether to be plain button | *boolean* | `false` |

View File

@ -128,7 +128,7 @@ Vue.use(Button);
| text | 按钮文字 | *string* | - |
| color `v2.1.8` | 按钮颜色,支持传入`linear-gradient`渐变色 | *string* | - |
| icon | 左侧[图标名称](#/zh-CN/icon)或图片链接 | *string* | - |
| icon-prefix `v2.5.3` | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | *string* | `van-icon` |
| icon-prefix `v2.6.0` | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | *string* | `van-icon` |
| tag | 根节点的 HTML 标签 | *string* | `button` |
| native-type | 原生 button 标签的 type 属性 | *string* | - |
| block | 是否为块级元素 | *boolean* | `false` |

View File

@ -166,6 +166,7 @@ Button.props = {
loading: Boolean,
hairline: Boolean,
disabled: Boolean,
iconPrefix: String,
nativeType: String,
loadingText: String,
loadingType: String,

View File

@ -1,6 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`loading size 1`] = `
exports[`icon-prefix prop 1`] = `
<button class="van-button van-button--default van-button--normal"><i class="my-icon my-icon-success van-button__icon">
<!----></i></button>
`;
exports[`loading-size prop 1`] = `
<button class="van-button van-button--default van-button--normal van-button--loading">
<div class="van-loading van-loading--circular van-button__loading"><span class="van-loading__spinner van-loading__spinner--circular" style="color: currentColor; width: 10px; height: 10px;"><svg viewBox="25 25 50 50" class="van-loading__circular"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span></div>
</button>

View File

@ -1,7 +1,7 @@
import { mount } from '../../../test';
import Button from '..';
test('loading size', () => {
test('loading-size prop', () => {
const wrapper = mount(Button, {
propsData: {
loading: true,
@ -82,3 +82,14 @@ test('hide border when color is gradient', () => {
expect(wrapper.element.style.border).toEqual('0px');
});
test('icon-prefix prop', () => {
const wrapper = mount(Button, {
propsData: {
icon: 'success',
iconPrefix: 'my-icon',
},
});
expect(wrapper).toMatchSnapshot();
});