可以通过以下方式将 view 中的文字居中对齐:

1. 设置 view 的 display 属性为 flex,将其子元素垂直和水平都居中对齐。

<view style='display:flex;justify-content:center;align-items:center;'>
  <text>Hello World!</text>
</view>

2. 设置 text 元素的 text-align 属性为 center,将其文字水平居中对齐。

<view>
  <text style='text-align:center;'>Hello World!</text>
</view>
Uniapp 文字居中对齐方法:Flex布局和text-align属性

原文地址: https://www.cveoy.top/t/topic/m1rT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录