You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.3 KiB
61 lines
1.3 KiB
<docs>
|
|
---
|
|
order: 7
|
|
title:
|
|
zh-CN: 更新消息内容
|
|
en-US: Update Message Content
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
可以通过唯一的 key 来更新内容, 或者通过响应式数据更新。
|
|
|
|
## en-US
|
|
|
|
Update content with unique key, or use reactive data.
|
|
|
|
</docs>
|
|
|
|
<template>
|
|
<a-button type="primary" @click="openNotification">
|
|
Open the notification box (update by key)
|
|
</a-button>
|
|
<br />
|
|
<br />
|
|
<a-button type="primary" @click="openNotification2">
|
|
Open the notification box (update by reactive)
|
|
</a-button>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
import { notification } from 'ant-design-vue';
|
|
import { ref } from 'vue';
|
|
const key = 'updatable';
|
|
const openNotification = () => {
|
|
notification.open({
|
|
key,
|
|
message: 'Notification Title',
|
|
description: 'description.',
|
|
});
|
|
setTimeout(() => {
|
|
notification.open({
|
|
key,
|
|
message: 'New Title',
|
|
description: 'New description.',
|
|
});
|
|
}, 1000);
|
|
};
|
|
const message = ref('Notification Title');
|
|
const description = ref('description');
|
|
const openNotification2 = () => {
|
|
// content must use function
|
|
notification.open({
|
|
message: () => message.value,
|
|
description: () => description.value,
|
|
});
|
|
setTimeout(() => {
|
|
message.value = 'New Title';
|
|
description.value = 'New description.';
|
|
}, 1000);
|
|
};
|
|
</script>
|