<script>
/**
使用示例:
网页链接 <Paragraph
:text="text"
/>
*/
export default {
props: {
// 显示的文本
text: {
type: String,
default: ''
},
// 最多展示的行数
maxLines: {
type: Number,
default: 3
},
// 组件宽
width: {
type: Number,
default: 0
},
// 展开
unfoldText: {
type: String,
default: '展开'
},
// 收起
foldText: {
type: String,
default: '收起'
},
// 是否使用Tooltip
tooltip: {
type: Boolean,
default: false
},
// 组件类型,expandable、tooltip、tooltipExpandable
type: {
type: String,
default: 'expandable'
},
// el-tooltip Attributes
tooltipAttrs: {
type: Object,
default: () => {
return {
effect: 'dark',
placement: 'top'
}
}
}
},
data() {
return {
offset: this.text.length, // 原始文本length
expanded: false, // 是否已展开
slotBoxWidth: 0, // 展开收起按钮宽度
textBoxWidth: this.width, // 展示的文本宽度
showSlotNode: false // 是否展示slot节点
}
},
computed: {
// 设置展示文本宽度
boxStyle() {
if (this.width) {
return {
width:
网页链接 + 'px'
}
} else {
return { width: 'auto' }
}
},