AutoTipZen 实时根据文字是否溢出 提示title
<template>
<div ref="autoTipRef"
@mouseover="onMouseOverHandle"
:title="innerTitle"
style="width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
<slot></slot>
</div>
</template>
<script>
export default {
name: 'AutoTipZen',
mixins: [],
props: {
value: {
type: String,
default: ''
}
},
components: {},
data () {
return {
innerTitle: '',
}
},
watch: {},
computed: {},
methods: {
onMouseOverHandle () {
const el = this.$refs.autoTipRef
// console.info('el', el.clientWidth, el.scrollWidth)
const isOverFlow = el.clientWidth < el.scrollWidth
if (isOverFlow) {
this.innerTitle = this.$slots.default[0].text
} else {
this.innerTitle = ''
}
}
},
filters: {},
created () { },
activated () { },
mounted () {
// console.info("$slots", this.$slots.default[0].text)
},
beforeUpdate () { },
beforeDestroy () { }
}
</script>
<style lang="less" scoped>
</style>
---------------------------------------------
生活的意义并不是与他人争高下,而在于享受努力实现目标的过程,结果是对自己行动的嘉奖。
↑面的话,越看越不痛快,应该这么说:
生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!