mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 17:51:54 +00:00
Merge branch 'dev' into next
This commit is contained in:
@@ -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 |
|
||||
|
@@ -155,3 +155,10 @@ Vue.use(Button);
|
||||
| ---------- | ---------------------------------------- | ------------------- |
|
||||
| click | 点击按钮,且按钮状态不为加载或禁用时触发 | _event: Event_ |
|
||||
| touchstart | 开始触摸按钮时触发 | _event: TouchEvent_ |
|
||||
|
||||
### Slots
|
||||
|
||||
| 名称 | 说明 |
|
||||
| ----------------- | -------------- |
|
||||
| default | 按钮内容 |
|
||||
| loading `v2.10.1` | 自定义加载图标 |
|
||||
|
@@ -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(
|
||||
|
@@ -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">
|
||||
|
@@ -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();
|
||||
});
|
||||
|
Reference in New Issue
Block a user