// script 标签引入,根据版本号引入JS版本。
<script src="https://websdk.videocc.net/interactions-receive-sdk-ui-default/0.24.0/lib/PcAnnouncement/PcAnnouncement.umd.min.js"></script>
// PC端
<script>
const Announcement = window.PolyvIRScene.PcAnnouncement.default;
</script>
// script 标签引入,根据版本号引入JS版本。
<script src="https://websdk.videocc.net/interactions-receive-sdk-ui-default/0.24.0/lib/MobileAnnouncement/MobileAnnouncement.umd.min.js"></script>
// 移动端
<script>
const Announcement = window.PolyvIRScene.MobileAnnouncement.default;
</script>
// PC 端
import Announcement from '@polyv/interactions-receive-sdk-ui-default/lib/PcAnnouncement';
// 移动端
import Announcement from '@polyv/interactions-receive-sdk-ui-default/lib/MobileAnnouncement';
<template>
<div v-show="isShowAnnouncement">
<h2>公告</h2>
<!-- 公告组件主体 -->
<announcement
:announcement-sdk="announcementSdk"
@to-show="setAnnouncementVisible(true)"
@to-hide="setAnnouncementVisible(false)"
/>
</div>
</template>
<script>
import { Announcement as AnnouncementSDK } from '@polyv/interactions-receive-sdk';
import Announcement from '@polyv/interactions-receive-sdk-ui-default/lib/PcAnnouncement';
export default {
components: {
Announcement,
},
data() {
return {
// 公告SDK实例
announcementSdk,
// 是否显示公告
isShowAnnouncement: false,
};
},
created() {
this.announcementSdk = new AnnouncementSDK();
},
beforeDestroy() {
this.announcementSdk?.destroy();
},
methods: {
setAnnouncementVisible(visible) {
this.isShowAnnouncement = visible;
},
},
};
</script>