[new feature] NoticeBar: add close event (#2692)

This commit is contained in:
neverland 2019-02-06 20:36:05 +08:00 committed by GitHub
parent 8fa872e52c
commit 9c5e5b8158
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 3 deletions

View File

@ -54,4 +54,5 @@ Vue.use(NoticeBar);
| Event | Description | Arguments |
|------|------|------|
| click | Triggered when click notice bar | - |
| click | Triggered when click NoticeBar | - |
| click | Triggered when closed | - |

View File

@ -60,7 +60,10 @@ export default sfc({
methods: {
onClickIcon() {
this.showNoticeBar = this.mode !== 'closeable';
if (this.mode === 'closeable') {
this.showNoticeBar = false;
this.$emit('close');
}
},
onAnimationEnd() {

View 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();
});

View File

@ -58,4 +58,5 @@ Vue.use(NoticeBar);
| 事件名 | 说明 | 参数 |
|------|------|------|
| click | 点击事件回调 | - |
| click | 点击时触发 | - |
| close | 关闭时触发 | - |