🐛(component): table

修复多选列错位问题
This commit is contained in:
dingyongya 2022-06-13 10:02:01 +08:00
parent 7981b1a4d9
commit 2115d1ec91

View File

@ -205,13 +205,9 @@ onMounted(() => {
const scrollWidth: number = tableBody.value?.scrollWidth || 0; const scrollWidth: number = tableBody.value?.scrollWidth || 0;
const offsetWidth: number = tableBody.value?.offsetWidth || 0; const offsetWidth: number = tableBody.value?.offsetWidth || 0;
console.dir(tableBody.value);
console.log(scrollWidth < offsetWidth);
console.log(scrollWidth, offsetWidth);
if (scrollWidth < offsetWidth) { if (scrollWidth < offsetWidth) {
scrollWidthCell.value = offsetWidth - scrollWidth; scrollWidthCell.value = offsetWidth - scrollWidth;
} }
console.log(props.columns);
tableBody.value?.addEventListener("scroll", () => { tableBody.value?.addEventListener("scroll", () => {
tableHeader.value!.scrollLeft = tableBody.value?.scrollLeft || 0; tableHeader.value!.scrollLeft = tableBody.value?.scrollLeft || 0;
}); });
@ -286,6 +282,7 @@ props.dataSource.map((value: any) => {
<div class="layui-table-header" ref="tableHeader"> <div class="layui-table-header" ref="tableHeader">
<table class="layui-table" :lay-size="size"> <table class="layui-table" :lay-size="size">
<colgroup> <colgroup>
<col v-if="checkbox" class="layui-table-col-special" />
<template v-for="column in columns" :key="column"> <template v-for="column in columns" :key="column">
<col <col
:width="column.width" :width="column.width"
@ -294,6 +291,7 @@ props.dataSource.map((value: any) => {
}" }"
/> />
</template> </template>
<col v-if="scrollWidthCell > 0" :width="scrollWidthCell" />
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
@ -361,6 +359,7 @@ props.dataSource.map((value: any) => {
> >
<table class="layui-table" :lay-size="size"> <table class="layui-table" :lay-size="size">
<colgroup> <colgroup>
<col v-if="checkbox" class="layui-table-col-special" />
<template v-for="column in columns" :key="column"> <template v-for="column in columns" :key="column">
<col <col
:width="column.width" :width="column.width"