Merge branch 'dev' into next

This commit is contained in:
chenjiahan
2020-08-09 20:40:22 +08:00
12 changed files with 169 additions and 151 deletions

View File

@@ -132,3 +132,10 @@ Vue.use(Button);
| --- | --- | --- |
| click | Triggered when click button and not disabled or loading | _event: Event_ |
| touchstart | Triggered when touch start | _event: TouchEvent_ |
### Slots
| Name | Description |
| ----------------- | ------------------- |
| default | Default slot |
| loading `v2.10.1` | Custom loading icon |

View File

@@ -155,3 +155,10 @@ Vue.use(Button);
| ---------- | ---------------------------------------- | ------------------- |
| click | 点击按钮,且按钮状态不为加载或禁用时触发 | _event: Event_ |
| touchstart | 开始触摸按钮时触发 | _event: TouchEvent_ |
### Slots
| 名称 | 说明 |
| ----------------- | -------------- |
| default | 按钮内容 |
| loading `v2.10.1` | 自定义加载图标 |

View File

@@ -63,12 +63,16 @@ export default createComponent({
if (this.loading) {
Content.push(
<Loading
class={bem('loading')}
size={this.loadingSize}
type={this.loadingType}
color="currentColor"
/>
this.$slots.loading ? (
this.$slots.loading()
) : (
<Loading
class={bem('loading')}
size={this.loadingSize}
type={this.loadingType}
color="currentColor"
/>
)
);
} else if (this.icon) {
Content.push(

View File

@@ -7,6 +7,12 @@ exports[`icon-prefix prop 1`] = `
</button>
`;
exports[`loading slot 1`] = `
<button class="van-button van-button--default van-button--normal van-button--loading">
<div class="van-button__content">Custom Loading</div>
</button>
`;
exports[`loading-size prop 1`] = `
<button class="van-button van-button--default van-button--normal van-button--loading">
<div class="van-button__content">

View File

@@ -93,3 +93,16 @@ test('icon-prefix prop', () => {
expect(wrapper).toMatchSnapshot();
});
test('loading slot', () => {
const wrapper = mount(Button, {
propsData: {
loading: true,
},
scopedSlots: {
loading: () => 'Custom Loading',
},
});
expect(wrapper).toMatchSnapshot();
});