mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 18:36:51 +08:00
[new feature] NoticeBar: add close event (#2692)
This commit is contained in:
parent
8fa872e52c
commit
9c5e5b8158
@ -54,4 +54,5 @@ Vue.use(NoticeBar);
|
|||||||
|
|
||||||
| Event | Description | Arguments |
|
| Event | Description | Arguments |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
| click | Triggered when click notice bar | - |
|
| click | Triggered when click NoticeBar | - |
|
||||||
|
| click | Triggered when closed | - |
|
||||||
|
@ -60,7 +60,10 @@ export default sfc({
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onClickIcon() {
|
onClickIcon() {
|
||||||
this.showNoticeBar = this.mode !== 'closeable';
|
if (this.mode === 'closeable') {
|
||||||
|
this.showNoticeBar = false;
|
||||||
|
this.$emit('close');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onAnimationEnd() {
|
onAnimationEnd() {
|
||||||
|
14
packages/notice-bar/test/index.spec.js
Normal file
14
packages/notice-bar/test/index.spec.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import NoticeBar from '..';
|
||||||
|
import { mount } from '../../../test/utils';
|
||||||
|
|
||||||
|
test('close event', () => {
|
||||||
|
const wrapper = mount(NoticeBar, {
|
||||||
|
propsData: {
|
||||||
|
mode: 'closeable'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const close = wrapper.find('.van-notice-bar__right-icon');
|
||||||
|
|
||||||
|
close.trigger('click');
|
||||||
|
expect(wrapper.emitted('close')).toBeTruthy();
|
||||||
|
});
|
@ -58,4 +58,5 @@ Vue.use(NoticeBar);
|
|||||||
|
|
||||||
| 事件名 | 说明 | 参数 |
|
| 事件名 | 说明 | 参数 |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
| click | 点击事件回调 | - |
|
| click | 点击时触发 | - |
|
||||||
|
| close | 关闭时触发 | - |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user