9433cfb9创建于 2025年12月31日历史提交
<template>
	<view style="flex: 1;">
		<text id="testText1" style="font-size: 20px; line-height: 2; lines: 2;">
			<text style="font-size: 20px; line-height: 2;background-color: red;">测试text设置lineHeight</text>
		</text>
		<text id="testText2" style="font-size: 20px; line-height: 2; lines: 2;">
			<text style="font-size: 20px; line-height: 2;background-color: red;">测试text嵌套多行文字设置lineHeight测试text嵌套多行文字设置</text>
		</text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				text1Height : 0,
				text2Height : 0
			}
		},
		onReady() {
			const testText1Ele = uni.getElementById("testText1") as UniElement
			const testText2Ele = uni.getElementById("testText2") as UniElement
			setTimeout(() => {
        this.text1Height = testText1Ele.getBoundingClientRect().height;
        this.text2Height = testText2Ele.getBoundingClientRect().height;
			}, 1000)
		},
		methods: {

		}
	}
</script>

<style>

</style>