mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[bugfix] NoticeBar: can't use stop modifier on click event (#3778)
This commit is contained in:
parent
968ec97256
commit
abc555dd72
@ -79,8 +79,8 @@ Vue.use(NoticeBar);
|
|||||||
|
|
||||||
| Event | Description | Arguments |
|
| Event | Description | Arguments |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
| click | Triggered when click NoticeBar | - |
|
| click | Triggered when click NoticeBar | event: Event |
|
||||||
| close | Triggered when closed | - |
|
| close | Triggered when closed | event: Event |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ Vue.use(NoticeBar);
|
|||||||
|
|
||||||
| 事件名 | 说明 | 回调参数 |
|
| 事件名 | 说明 | 回调参数 |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
| click | 点击通知栏时触发 | - |
|
| click | 点击通知栏时触发 | event: Event |
|
||||||
| close | 关闭通知栏时触发 | - |
|
| close | 关闭通知栏时触发 | event: Event |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -60,10 +60,10 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onClickIcon() {
|
onClickIcon(event) {
|
||||||
if (this.mode === 'closeable') {
|
if (this.mode === 'closeable') {
|
||||||
this.showNoticeBar = false;
|
this.showNoticeBar = false;
|
||||||
this.$emit('close');
|
this.$emit('close', event);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -121,8 +121,8 @@ export default createComponent({
|
|||||||
vShow={this.showNoticeBar}
|
vShow={this.showNoticeBar}
|
||||||
class={bem({ wrapable: this.wrapable })}
|
class={bem({ wrapable: this.wrapable })}
|
||||||
style={barStyle}
|
style={barStyle}
|
||||||
onClick={() => {
|
onClick={event => {
|
||||||
this.$emit('click');
|
this.$emit('click', event);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{LeftIcon()}
|
{LeftIcon()}
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
import NoticeBar from '..';
|
import NoticeBar from '..';
|
||||||
import { mount } from '../../../test/utils';
|
import { mount } from '../../../test/utils';
|
||||||
|
|
||||||
|
test('click event', () => {
|
||||||
|
const wrapper = mount(NoticeBar);
|
||||||
|
|
||||||
|
wrapper.trigger('click');
|
||||||
|
expect(wrapper.emitted('click')[0][0]).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
test('close event', () => {
|
test('close event', () => {
|
||||||
const wrapper = mount(NoticeBar, {
|
const wrapper = mount(NoticeBar, {
|
||||||
propsData: {
|
propsData: {
|
||||||
@ -10,7 +17,7 @@ test('close event', () => {
|
|||||||
const close = wrapper.find('.van-notice-bar__right-icon');
|
const close = wrapper.find('.van-notice-bar__right-icon');
|
||||||
|
|
||||||
close.trigger('click');
|
close.trigger('click');
|
||||||
expect(wrapper.emitted('close')).toBeTruthy();
|
expect(wrapper.emitted('close')[0][0]).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('icon slot', () => {
|
test('icon slot', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user