Dialog 分为两个部分:body
和 footer。
footer
需要具名为 footer
的 slot
。
name 为 footer 里面的 el-button 会插入到 组件el-dialog 中 footer的地方。
<el-button type="text" @click="dialogVisible = true">点击打开 Dialog</el-button>
<el-dialog
title="提示"
:visible.sync="dialogVisible"
width="30%"
:before-close="handleClose">
<span>这是一段信息</span>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
</span>
</el-dialog>
参考:
https://www.w3cplus.com/vue/vue-slot.html(比较详细,包括vue生命周期图)