index.vue
1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<template>
<div class="basic-panel">
<el-popover placement="top" popper-class="base-popper" trigger="hover" :content="content" v-if="tooltipStatus">
<div class="basic-title" slot="reference">{{ content | ellipsis(this) }}</div>
</el-popover>
<div class="basic-title" v-else>{{ content | ellipsis(this) }}</div>
</div>
</template>
<script>
export default {
name: 'basic-dialog',
props: {
content: {
type: String,
default: ''
},
textLength: {
type: Number,
default: 8
}
},
data() {
return {
tooltipStatus: false
}
},
filters: {
ellipsis(value,that) {
if (value.length > that.textLength) {
that.tooltipStatus = true
return value.slice(0, that.textLength) + '...'
}
return value
}
},
mounted() {
// this.$nextTick(() => {
// const title = document.querySelector('.basic-title-s')
// console.log(title.innerText, this.content)
// if (title.innerText == this.content) {
// this.tooltipStatus = false
// } else {
// this.tooltipStatus = true
// }
// })
}
}
</script>
<style lang="scss">
.basic-panel {
display: inline-block;
}
</style>