美文网首页
element相关

element相关

作者: 科科Cole | 来源:发表于2020-11-16 10:28 被阅读0次

el-dialog

el-dialog作为子组件时,created()mounted()会在页面加载时就执行,visible.sync只是控制dialog显示相当于display。对于需要在dialog显示时执行的方法,有两种解决方法:
1 <el-dialog visible.sync="isDialogShow" v-if="isDialogShow"> v-if与visible同时控制dialog显示。
2 <el-dialog visible.sync="isDialogShow" @open="onDialogOpen">绑定el-dialog的open事件,dialog打开时执行回调函数。

<el-dialog :before-close="isDialogShow = false"> 设置dialog关闭前的回调函数,否则点击dialog右上角关闭按钮关闭时控制台可能会报错。

当dialog上有表单时,关闭dialog再打开时表单内容还在,不会自动清空,有两种解决方法:
1 监听isDialogShow,当isDialogShowtrue时,执行form.resetFields()
2 <el-dialog @close="onDialogClose"> 绑定el-dialog的close事件,dialog关闭时执行form.resetFields()
使用 :destroy-on-close="true"是不行的,原因可以看这篇文章element destroy-on-close属性使用踩坑

el-table

<el-table-column type="selection"> 可以添加表格选择列

<el-table row-key="id" @selection-change="onTableSelected"> <el-table-column type="selection" :reserve-selection="true"> 配合使用可以实现跨页选择,详见Element UI表格组件技巧:如何简洁实现跨页勾选、跨页统计功能

<el-table-column> <template slot-scope="scope"> {{scope.$index + (page-1)*size + 1}} </template> </el-table-column> 可以实现表格序号

相关文章

网友评论

      本文标题:element相关

      本文链接:https://www.haomeiwen.com/subject/ovsabktx.html