Commit 860de73e by luyt

add:省略宽度自定义

1 parent 178e12b2
......@@ -101,7 +101,8 @@ export default {
{
label: '直播间名称',
prop: 'name',
line: 1
line: 2,
width:350
// children:[
// {
// label: '直播间名称1',
......@@ -185,7 +186,7 @@ export default {
name2: '123'
},
{
name: '王小虎王小虎王小虎王王小虎王小虎王小虎王',
name: '王小虎王小虎王小虎王王小虎王小虎王小虎王王小虎王小虎王小虎王王小虎王小虎王小虎王小虎王小虎王王小虎王小虎王小虎王',
liveStatus3: '132',
liveStatus4: '789',
name1: '123',
......
const lineEllipsis = (value,line = 1) => {
const lineEllipsis = (value,columnWidth,line = 1) => {
if (!value) return ''
// 假设一行的宽是字的个数10
const strleng = 10 * line - 2
// 假设一行的宽是字的个数10 160px的宽度 一个汉字16px
const strleng = Math.ceil(columnWidth/16) * line - 2
if (value.length > strleng) {
return value.substring(0, strleng) + '...'
}
......
......@@ -13,9 +13,9 @@
<template slot-scope="scope">
<slot v-if="item.addHtml" :name="item.addHtml" :scope="scope.row" :prop="item.prop" :width="item.width"></slot>
<template v-else-if="item.formatter">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= 10 * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="item.formatter(scope.row)">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil(item.width / 16) * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="item.formatter(scope.row)">
<span slot="reference" class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ item.formatter(scope.row) | lineEllipsis(item.line) }}
{{ item.formatter(scope.row) | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
......@@ -23,9 +23,9 @@
</span>
</template>
<template v-else-if="getListApi">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= 10 * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="scope.row[item.prop]">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil(item.width / 16) * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="scope.row[item.prop]">
<span slot="reference" class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ scope.row[item.prop] | lineEllipsis(item.line) }}
{{ scope.row[item.prop] | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
......@@ -35,9 +35,9 @@
<template v-else>
<!-- 大于10或 20个字节长度 宽度160px -->
<el-popover v-if="tableData[scope.$index][item.prop] && tableData[scope.$index][item.prop].length >= 10 * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="tableData[scope.$index][item.prop]">
<el-popover v-if="tableData[scope.$index][item.prop] && tableData[scope.$index][item.prop].length >= Math.ceil(item.width / 16) * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="tableData[scope.$index][item.prop]">
<span slot="reference" class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ tableData[scope.$index][item.prop] | lineEllipsis(item.line) }}
{{ tableData[scope.$index][item.prop] | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="tableData[scope.$index][item.prop]"></span>
......
......@@ -4,18 +4,18 @@
<template slot-scope="scope">
<slot v-if="item.addHtml" :name="item.addHtml" :scope="scope.row" :prop="item.prop" :width="item.width"></slot>
<template v-else-if="item.formatter">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= 10 * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="item.formatter(scope.row)">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil(item.width / 16) * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="item.formatter(scope.row)">
<span slot="reference" class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ item.formatter(scope.row) | lineEllipsis(item.line) }}
{{ item.formatter(scope.row) | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="item.formatter(scope.row)"></span>
</template>
<template v-else-if="getListApi">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= 10 * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="scope.row[item.prop]">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil(item.width / 16) * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="scope.row[item.prop]">
<span slot="reference" class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ scope.row[item.prop] | lineEllipsis(item.line) }}
{{ scope.row[item.prop] | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="scope.row[item.prop]"></span>
......@@ -24,14 +24,14 @@
<template v-else>
<!-- 大于10或 20个字节长度 -->
<el-popover v-if="tableData[scope.$index][item.prop] && tableData[scope.$index][item.prop].length >= 10 * item.line" placement="top" width="200" trigger="hover" :content="tableData[scope.$index][item.prop]">
<el-popover v-if="tableData[scope.$index][item.prop] && tableData[scope.$index][item.prop].length >= Math.ceil(item.width / 16) * item.line" placement="top" width="200" trigger="hover" :content="tableData[scope.$index][item.prop]">
<span slot="reference" class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ tableData[scope.$index][item.prop] | lineEllipsis(item.line) }}
{{ tableData[scope.$index][item.prop] | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<!-- <span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="tableData[scope.$index][item.prop]"></span> -->
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{tableData[scope.$index][item.prop] }}
{{ tableData[scope.$index][item.prop] }}
</span>
</template>
<template v-if="item.addSymbol">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!