How to build a pop-up window component with Vue to realize queue mechanism and automatic destruction

  1. how do I create this component dynamically? (for example, calling the component to display information after AJAX)
  2. how to destroy automatically? (for example, automatically destroy or hide after a successful creation)
  3. how do I queue multiple components created at the same time? (show the next one immediately after the previous component disappears)

       <div id="atn">
           <todo-item
             v-for="(item,index) in msg_list"
             v-bind:todo="item"
             v-bind:key="item.index"
             v-show="item.show">
           </todo-item>
       </div>
       <script>
           // 
       Vue.component("todo-item", {
         props: ["todo"],
         template: "<div class="atn-msg">@{{ todo.text }}</div>"
       })
       // 
       var app = new Vue({
         el: "-sharpatn",
         data: {
           msg_list: [
             {text: "1",show:true },
             {text: "2",show:false },
           ]
         }
       })
       </script>
       
       <style>
       .atn-msg{
           position: fixed;
           z-index: 1000;
           bottom: 20vh;
           left: 50%;
           display: flex;
           justify-content: center;
           align-items: center;
           padding: .5rem 1rem;
           border-radius: 20rem;
           background: rgba(0,0,0,0.5);
           color: -sharpfff;
           animation-duration: .4s;
           animation-fill-mode: forwards;
           animation-name: fadeIn;
       }
       </style>
Feb.27,2021

you can take a look at the source code of the message component of iview.

is divided into two parts:

1, manage objects. Save the pop-up queue, create and destroy methods, and all the logic you want to implement is in this management object.

2. The pop-up component is a stateless component. Simply do the content display.

Menu