ant-design-vue/components/notification/demo/with-btn.md

52 lines
1.2 KiB
Markdown
Raw Normal View History

2018-02-06 07:21:13 +00:00
<cn>
2018-09-21 02:00:52 +00:00
#### 自定义按钮
自定义关闭按钮的样式和文字。
2018-02-06 07:21:13 +00:00
</cn>
<us>
2018-09-21 02:00:52 +00:00
#### Custom close button
To customize the style or font of the close button.
2018-02-06 07:21:13 +00:00
</us>
2019-10-09 10:32:23 +00:00
```tpl
2018-02-06 07:21:13 +00:00
<template>
<a-button type="primary" @click="openNotification">Open the notification box</a-button>
</template>
<script>
const close = () => {
2019-09-28 12:45:07 +00:00
console.log(
'Notification was closed. Either the close button was clicked or duration time elapsed.',
);
2018-02-06 07:21:13 +00:00
};
export default {
methods: {
2019-09-28 12:45:07 +00:00
openNotification() {
2018-02-06 07:21:13 +00:00
const key = `open${Date.now()}`;
2018-04-08 13:17:20 +00:00
this.$notification.open({
2018-02-06 07:21:13 +00:00
message: 'Notification Title',
2019-09-28 12:45:07 +00:00
description:
'A function will be be called after the notification is closed (automatically after the "duration" time of manually).',
btn: h => {
return h(
'a-button',
{
props: {
type: 'primary',
size: 'small',
},
on: {
click: () => this.$notification.close(key),
},
2018-02-06 07:21:13 +00:00
},
2019-09-28 12:45:07 +00:00
'Confirm',
);
2018-02-06 07:21:13 +00:00
},
key,
onClose: close,
});
},
2019-09-28 12:45:07 +00:00
},
};
2018-02-06 07:21:13 +00:00
</script>
```