1. <template>
    2. <div class="about">
    3. <h1>This is an about page</h1>
    4. <Dialog v-show="isShow" @Del="handleDel"></Dialog>
    5. <button @click="toggle">切换</button>
    6. </div>
    7. </template>
    8. <script>
    9. import Dialog from '@/components/Dialog.vue'
    10. export default {
    11. data(){
    12. return{
    13. isShow:false
    14. }
    15. },
    16. components:{
    17. Dialog
    18. },
    19. methods:{
    20. toggle(){
    21. this.isShow=true
    22. },
    23. handleDel(){
    24. this.isShow = false
    25. }
    26. }
    27. }
    28. </script>
    1. <template>
    2. <div class="container">
    3. <p class="font-1">只爱西经</p>
    4. <p>任西关情劫千千重,千观色相偏看重,镜不染尘凡心动</p>
    5. <button @click="handleDel">取消</button>
    6. </div>
    7. </template>
    8. <script>
    9. export default {
    10. name:"Dialog",
    11. methods:{
    12. handleDel(){
    13. this.$emit("Del")
    14. }
    15. }
    16. }
    17. </script>
    18. <style scoped>
    19. .font-1{
    20. font-size: 20px;
    21. }
    22. .container{
    23. position: absolute;
    24. top: 0;
    25. left: 0;
    26. right: 0;
    27. bottom: 0;
    28. background: rgba(51, 51, 51, 0.4);
    29. width: 400px;
    30. margin-left: auto;
    31. margin-right: auto;
    32. }
    33. </style>