项目需求需要在弹框的标题行添加下载按钮,一开始看官方文档,没有找到解决方法,官方的按钮都是放在弹框底部的,官方文档中有个slot,没看懂啥意思,但是解决的方法就是它
利用插巢slot给el-dialog弹框标题添加下载按钮
<el-dialog
v-dialogDrag
top="25vh"
:visible.sync="dialogFormVisible"
append-to-body
:close-on-click-modal=false
>
<div slot="title" class="header-title">
<span> {{this.tableTitle}} </span>
<download-excel :data="tableData" :fields="json_fields" :name="fileName">
<el-button type="primary" id="exportBtn" style="margin:-26px 40px;padding:0.08rem 0.16rem;float:right">导出</el-button>
</download-excel>
</div>
</el-dialog>
利用插巢slot给el-dialog弹框标题添加图标及标题,弹框内嵌套表格
<el-dialog :title="title" :visible.sync="dialogVisible">
<div slot="title" class="header-title">
<img :src="src" alt="">
<span>{{title}}</span>
</div>
<el-table :data="gridData" height="308">
<el-table-column property="date" label="日期" width="80" align="center"></el-table-column>
<el-table-column property="name" label="名称" width="120"></el-table-column>
<el-table-column property="address" label="地址" show-overflow-tooltip></el-table-column>
</el-table>
</el-dialog>