这么一个简单的问题,在网上愣是找不到一个拿来即用的方法,这里记录一下:
文字换行且靠左
<view style="text-align: left">
<text>第一行</text>
<text>\n第二行</text>
</view>
换行直接用“\n”。很暴力
一行文字靠上,一行文字靠下
在一个子空间中,摆放两行文字
<view style="display: flex; flex-direction: column; height: 100px; text-align: left">
<text>第一行</text>
<text style="margin-bottom: 0%">\n第二行</text>
</view>
- 为了效果演示,我限制了父元素的高度为100px。
- 布局需要是
display: flex;
- 且布局的主轴为垂直方向,起点在上沿
flex-direction: column;
- 最后设置需要靠下的文字的外下边距为0,这样他就靠下了
margin-bottom: 0%
PS:这个css样式应该通用,不限制在uni-app。