使用封装组件:
<panel-dialog :visible.sync="dialogShow" title="xxxx详情信息" width="40%">
<div>
Hello word
</div>
<div slot="footer">
<el-button class="submit" @click="dialogSubmit()">确定</el-button>
<el-button class="rest" @click="dialogRestFn()">重置</el-button>
</div>
</panel-dialog>
组件封装:
<template v-if="dialogVisible">
// <template v-if="dialogVisible"> 确保有时候弹窗再次打开执行特定的函数,或者恢复最初状态
<el-dialog
:class="{'animated':true, 'fadeOutDown': !dialogVisible, 'fadeInDown': dialogVisible}" :title="title" :visible.sync="dialogVisible" :width="width" @close="close" :close-on-click-modal="false" :modal-append-to-body="false">
<slot></slot>
<div slot="footer" class="dialog-footer">
<slot name="footer"></slot>
</div>
</el-dialog>
</template>
<script>
export default {
name: "PanelDialog",
props: {
title: {
type: String,
default: "",
},
visible: {
type: Boolean,
default: false,
},
width: {
type: String,
default: "",
},
},
data() {
return {
dialogVisible: false,
};
},
methods: {
close() {
this.$emit('dialogClose');
this.$emit("update:visible", false);
},
},
watch: {
visible(val) {
this.dialogVisible = val;
},
},
};
</script>
<style scoped>
.el-dialog__body {
padding: 0;
color: #606266;
font-size: 0.14rem;
}
.dialog-footer {
text-align: center;
}
</style>