Vue 组件:可定制化的对话框组件 - 实现弹框功能
<p>"<template>\n <div>\n <!-- <div class="dialog-wrap">\n <div class="dialog-cover" v-if="isShow" @click="closeMyself"></div>\n <transition name="drop">\n <div class="dialog-content" v-if="isShow">\n <p class="dialog-close" @click="closeMyself">x</p>\n <slot>empty</slot>\n </div>\n </transition>\n </div> -->\n <el-dialog title="提示" :visible.sync="isShow" width="40%" :before-close="handleClose">\n <slot>empty</slot>\n </el-dialog>\n\n </div>\n</template>\n\n<script type="text/ecmascript-6">\n export default {\n props: {\n isShow: {\n type: Boolean,\n default: false\n },\n type: {\n type: String,\n default: 'login'\n }\n },\n data() {\n return {\n\n }\n },\n methods: {\n changeShow() {\n this.isShow = true\n },\n closeMyself() {\n this.$emit('on-close')\n },\n handleClose() {\n this.isShow = false\n if (this.type === 'login') {\n\n } else {\n this.$router.push({ path: '/orderList' })\n }\n\n }\n }\n }\n</script>\n\n<style scoped>\n .drop-enter-active {\n transition: all .5s ease;\n }\n\n .drop-leave-active {\n transition: all .3s ease;\n }\n\n .drop-enter {\n transform: translateY(-500px);\n }\n\n .drop-leave-active {\n transform: translateY(-500px);\n }\n\n .dialog-wrap {\n position: fixed;\n width: 100%;\n height: 100%;\n }\n\n .dialog-cover {\n background: #000;\n opacity: .3;\n position: fixed;\n z-index: 5;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n }\n\n .dialog-content {\n width: 50%;\n position: fixed;\n max-height: 50%;\n overflow: auto;\n background: #fff;\n top: 20%;\n left: 50%;\n margin-left: -25%;\n z-index: 10;\n padding: 2%;\n line-height: 1.6;\n box-shadow: #747474;\n }\n\n .dialog-close {\n position: absolute;\n right: 5px;\n top: 5px;\n width: 20px;\n height: 20px;\n text-align: center;\n cursor: pointer;\n }\n\n .dialog-close:hover {\n color: linear-gradient(248deg, #ff8c1f, #ff6a00);\n }\n</style>\n这个前端代码的意思内容:这是一个Vue组件的代码,用于显示一个对话框。组件包含一个<code><el-dialog></code>元素,用于显示对话框的内容。<code>isShow</code>属性控制对话框的可见性,<code>type</code>属性指定对话框的类型,默认为登录类型。\n\n对话框的内容通过插槽 <code><slot></code> 进行传递,如果没有传递内容,则显示默认内容“empty”。\n\n<code>changeShow</code>方法用于改变对话框的可见性,<code>closeMyself</code>方法用于关闭对话框。<code>handleClose</code>方法在对话框关闭前被调用,根据对话框的类型进行不同的处理,例如跳转到订单列表页面。\n\n样式部分使用了一些CSS样式,包括动画效果和对话框的布局样式。\n\n需要注意的是,这段代码中的一部分被注释掉了,可能是之前的实现方式或者备用代码。</p>
原文地址: https://www.cveoy.top/t/topic/pyYW 著作权归作者所有。请勿转载和采集!