el-dialog本身只支持标题栏右上角有关闭按钮,故需要使用slot=“title” 重写覆盖原本的标题栏。
效果图:
组件代码:dialogHeader.vue
<template>
<div class="header-title">
<span class="title-name">{{ dialogTittle }}</span>
<span
style="float: right; margin-right: 44px; margin-top: 9px;color:#909399; cursor: pointer;"
:class="flodIconClass"
@click="() => isFullscreen"></span>
</div>
</template>
<script>
export default {
props: {
dialogTittle: {
type: String,
default: () => ''
},
fullscreen: {
type: Boolean,
default: () => false
}
},
data () {
return {
header_box: {
'display': 'flex',
'align-items': 'center'
}
}
},
computed: {
flodIconClass() {
return this.fullscreen ? 'el-icon-full-screen' : 'el-icon-copy-document';
},
isFullscreen() {
this.$emit('is-fullscreen', !this.fullscreen);
},
closed() {
this.$emit('handle-closed', 2)
}
},
created() {
},
methods: {
},
mounted() {
},
}
</script>
1 导入注册组件
2 使用dialogHeader组件
3 是否为全屏
相似博客