vue中簡單彈框dialog的實現(xiàn)方法
更新時間:2018年02月26日 10:14:01 投稿:jingxian
下面小編就為大家分享一篇vue中簡單彈框dialog的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
效果如下,dialog中內(nèi)容自行添加
<template> <div> <div class="dialog-wrap"> <div class="dialog-cover" v-if="isShow" @click="closeMyself"></div> <transition name="drop"> <div class="dialog-content" v-if="isShow"> <p class="dialog-close" @click="closeMyself">x</p> <slot>empty</slot> </div> </transition> </div> </div> </template>
接收父組件傳參isShow,并返回一個自定義事件on-close
<script> export default { props: { isShow: { type: Boolean, default: false } }, data () { return { } }, methods: { closeMyself () { this.$emit('on-close') } } } </script>
<style scoped> .drop-enter-active { transition: all .5s ease; } .drop-leave-active { transition: all .3s ease; } .drop-enter { transform: translateY(-500px); } .drop-leave-active { transform: translateY(-500px); } .dialog-wrap { position: fixed; width: 100%; height: 100%; } .dialog-cover { background: #000; opacity: .3; position: fixed; z-index: 5; top: 0; left: 0; width: 100%; height: 100%; } .dialog-content { width: 50%; position: fixed; max-height: 50%; overflow: auto; background: #fff; top: 20%; left: 50%; margin-left: -25%; z-index: 10; border: 2px solid #464068; padding: 2%; line-height: 1.6; } .dialog-close { position: absolute; right: 5px; top: 5px; width: 20px; height: 20px; text-align: center; cursor: pointer; } .dialog-close:hover { color: #4fc08d; } </style>
以上這篇vue中簡單彈框dialog的實現(xiàn)方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
全面解析vue router 基本使用(動態(tài)路由,嵌套路由)
路由,其實就是指向的意思,當我點擊頁面上的home按鈕時,頁面中就要顯示home的內(nèi)容,如果點擊頁面上的about 按鈕,頁面中就要顯示about 的內(nèi)容。這篇文章主要介紹了vue router 基本使用 ,需要的朋友可以參考下2018-09-09vue.js動態(tài)修改background-image問題
這篇文章主要介紹了vue.js動態(tài)修改background-image問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-08-08vue項目使用高德地圖的定位及關(guān)鍵字搜索功能的實例代碼(踩坑經(jīng)驗)
這篇文章主要介紹了vue項目使用高德地圖的定位及關(guān)鍵字搜索功能的實例代碼,也是小編踩了無數(shù)坑總結(jié)出來的經(jīng)驗,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2020-03-03