uniapp使用uni-tooltip自定义多行

发布时间 2024-01-08 16:28:41作者: 乌拉小考

uniapp的官方文档中uni-tooltip的直接示例没有写全多行tooltip的演示代码,所以记录一下。主要就是利用插槽自己定义一个view,然后设置他的宽度来设置宽度高度,以及设置文字换行。

<template>
<uni-tooltip>
				<button size="mini">多行文字提示</button>
				<template v-slot:content>
					<view class="uni-stat-tooltip">
						一段文字一段文字一段文字一段文字一段文字一段文字一段文字
						一段文字一段文字一段文字一段文字一段文字一段文字一段文字
					</view>
				</template>
			</uni-tooltip>
</template>
<style lang="scss">
	.uni-stat-tooltip {
  max-width: 400rpx;
  max-height: 400rpx;
  overflow: scroll;
  word-break: break-word;
	}
</style>