vue.js - 如何在 VueJS 中将完全编译的组件动态附加到 DOM
问题描述
我正在尝试制作弹出通知之类的东西。
- 每个通知都将异步创建。(随机间隔)
- 每个通知都是一个组件。
Eg. <my-notification ... />
- 主要组件
<notification-manager />
应该能够创建 N 个通知。
解决方案
<template>
<my-notification v-for="notification in notifications" :notification="notification" />
</template>
<script>
export default {
data(){
notifications: []
},
async created() {
var notification = await getNotificaiton();
this.notifications.push(notification);
// Keep on pushing as you get
}
}
</script>