mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(CountDown): add change event (#5599)
This commit is contained in:
parent
b83bed3b6c
commit
1404c82dba
@ -130,6 +130,7 @@ export default {
|
|||||||
| Event | Description | Arguments |
|
| Event | Description | Arguments |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
| finish | Triggered when count down finished | - |
|
| finish | Triggered when count down finished | - |
|
||||||
|
| change `2.4.4` | Triggered when count down changed | timeData |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -140,6 +140,7 @@ export default {
|
|||||||
| 事件名 | 说明 | 回调参数 |
|
| 事件名 | 说明 | 回调参数 |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
| finish | 倒计时结束时触发 | - |
|
| finish | 倒计时结束时触发 | - |
|
||||||
|
| change `2.4.4` | 倒计时变化时触发 | timeData |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -141,6 +141,7 @@ export default createComponent({
|
|||||||
|
|
||||||
setRemain(remain) {
|
setRemain(remain) {
|
||||||
this.remain = remain;
|
this.remain = remain;
|
||||||
|
this.$emit('change', this.timeData);
|
||||||
|
|
||||||
if (remain === 0) {
|
if (remain === 0) {
|
||||||
this.pause();
|
this.pause();
|
||||||
|
@ -213,3 +213,21 @@ test('pause when deactivated', async () => {
|
|||||||
wrapper.setData({ render: true });
|
wrapper.setData({ render: true });
|
||||||
expect(countDown.counting).toBeFalsy();
|
expect(countDown.counting).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('change event', async () => {
|
||||||
|
const wrapper = mount(CountDown, {
|
||||||
|
propsData: {
|
||||||
|
time: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.emitted('change')).toBeFalsy();
|
||||||
|
await later(50);
|
||||||
|
expect(wrapper.emitted('change')[0][0]).toEqual({
|
||||||
|
days: 0,
|
||||||
|
hours: 0,
|
||||||
|
milliseconds: 0,
|
||||||
|
minutes: 0,
|
||||||
|
seconds: 0,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user