需求:在el-dialog中展现一个表格,支持区域选取实现批量设置。于是想到用vxe-table来实现。
代码如下
<el-dialog
v-dialogDrag
:title="dialogTitle"
width="30%"
:visible.sync="createVisible"
center
>
<Create />
<span slot="footer" class="dialog-footer">
<el-button @click="createStatus()">取 消</el-button>
<el-button type="primary" @click="sureCreate">确 定</el-button>
</span>
</el-dialog>
子组件<Create />为vxe-table实现表格,这里展示部分代码,其中:mouse-config="{ checked: true, selected: true }"控制是否可以区域选择。
<vxe-table
ref="vxeTableRef"
class="mytable-style"
border
resizable
:data="formData.ratioList"
:mouse-config="{ checked: true, selected: true }"
:keyboard-config="{ isArrow: true, isTab: true, isEdit: true }"
>
效果如下:
实现后突然发现不能进行区域选取,反复找了好久没找到问题所在。最后我在看弹窗代码时发现了问题。v-dialogDrag是控制弹窗可以实现拖动的开关,把这个去掉之后问题解决了。
总结:应该是弹窗的 v-dialogDrag和vxe-table的区域选择冲突导致。