Vue.js 如何在VueJS中将完全编译的组件动态附加到DOM中
我正在尝试做一些类似弹出式通知的东西Vue.js 如何在VueJS中将完全编译的组件动态附加到DOM中,vue.js,Vue.js,我正在尝试做一些类似弹出式通知的东西 每个通知都将异步创建。(随机间隔) 每个通知都将是一个组件例如 主组件应该能够创建N个通知 导出默认值{ 数据(){ 通知:[] }, 异步创建(){ var notification=wait getNotificaiton(); this.notifications.push(通知); //在你到达的时候继续推动 } } 查看此示例: <template> <my-notification v-for="notificati
- 每个通知都将异步创建。(随机间隔)
- 每个通知都将是一个组件<代码>例如
- 主组件
应该能够创建N个通知
导出默认值{
数据(){
通知:[]
},
异步创建(){
var notification=wait getNotificaiton();
this.notifications.push(通知);
//在你到达的时候继续推动
}
}
查看此示例:
<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>