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.
ant-design-vue/components/notification/demo/placement.vue

72 lines
1.7 KiB

<docs>
---
order: 6
title:
zh-CN: 位置
en-US: Placement
---
## zh-CN
可以设置通知从右上角右下角左下角左上角弹出
## en-US
A notification box can pop up from `topRight` or `bottomRight` or `bottomLeft` or `topLeft`.
</docs>
<template>
<div>
<a-button type="primary" @click="openNotification('topLeft')">
<radius-upleft-outlined />
topLeft
</a-button>
<a-button type="primary" @click="openNotification('topRight')">
<radius-upright-outlined />
topRight
</a-button>
<a-divider />
<a-button type="primary" @click="openNotification('bottomLeft')">
<radius-bottomleft-outlined />
bottomLeft
</a-button>
<a-button type="primary" @click="openNotification('bottomRight')">
<radius-bottomright-outlined />
bottomRight
</a-button>
</div>
</template>
<script lang="ts">
import {
RadiusUpleftOutlined,
RadiusUprightOutlined,
RadiusBottomleftOutlined,
RadiusBottomrightOutlined,
} from '@ant-design/icons-vue';
import { notification } from 'ant-design-vue';
import { defineComponent } from 'vue';
import type { NotificationPlacement } from 'ant-design-vue';
export default defineComponent({
components: {
RadiusUpleftOutlined,
RadiusUprightOutlined,
RadiusBottomleftOutlined,
RadiusBottomrightOutlined,
},
setup() {
const openNotification = (placement: NotificationPlacement) => {
notification.open({
message: `Notification ${placement}`,
description:
'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
placement,
});
};
return {
openNotification,
};
},
});
</script>