Tooltip add maxWidth prop
This commit is contained in:
parent
16e850535b
commit
6b498dd1a4
3 changed files with 27 additions and 4 deletions
|
@ -1,9 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div style="margin: 200px;">
|
||||||
<Tooltip always placement="top" transfer :content="text" :delay="1000" theme="light">
|
<Tooltip always placement="top-end" transfer :content="text" :delay="1000" theme="light">
|
||||||
<Button @click="disabled = true">延时1秒显示</Button>
|
<Button @click="disabled = true">延时1秒显示</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip placement="top" transfer :content="text">
|
<Tooltip always transfer :max-width="200" content="我的文本超级无敌长我的文本超级无敌长我的文本超级无敌长我的文本超级无敌长我的文本超级无敌长我的文本超级无敌长">
|
||||||
<Button @click="handleChange">change</Button>
|
<Button @click="handleChange">change</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Button @click="handleChange">change</Button>
|
<Button @click="handleChange">change</Button>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
v-transfer-dom>
|
v-transfer-dom>
|
||||||
<div :class="[prefixCls + '-content']">
|
<div :class="[prefixCls + '-content']">
|
||||||
<div :class="[prefixCls + '-arrow']"></div>
|
<div :class="[prefixCls + '-arrow']"></div>
|
||||||
<div :class="[prefixCls + '-inner']"><slot name="content">{{ content }}</slot></div>
|
<div :class="innerClasses" :style="innerStyles"><slot name="content">{{ content }}</slot></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
|
@ -67,6 +67,9 @@
|
||||||
return oneOf(value, ['dark', 'light']);
|
return oneOf(value, ['dark', 'light']);
|
||||||
},
|
},
|
||||||
default: 'dark'
|
default: 'dark'
|
||||||
|
},
|
||||||
|
maxWidth: {
|
||||||
|
type: Number
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -74,6 +77,21 @@
|
||||||
prefixCls: prefixCls
|
prefixCls: prefixCls
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
innerStyles () {
|
||||||
|
const styles = {};
|
||||||
|
if (this.maxWidth) styles['max-width'] = `${this.maxWidth}px`;
|
||||||
|
return styles;
|
||||||
|
},
|
||||||
|
innerClasses () {
|
||||||
|
return [
|
||||||
|
`${prefixCls}-inner`,
|
||||||
|
{
|
||||||
|
[`${prefixCls}-inner-with-width`]: !!this.maxWidth
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
content () {
|
content () {
|
||||||
this.updatePopper();
|
this.updatePopper();
|
||||||
|
|
|
@ -71,6 +71,11 @@
|
||||||
border-radius: @border-radius-small;
|
border-radius: @border-radius-small;
|
||||||
box-shadow: @shadow-base;
|
box-shadow: @shadow-base;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
|
&-with-width{
|
||||||
|
white-space: pre-wrap;
|
||||||
|
text-align: justify;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-light &-inner{
|
&-light &-inner{
|
||||||
|
|
Loading…
Add table
Reference in a new issue