使用 nativescript 在 stacklayout 中居中带有标签的文本

Center text with label in stacklayout with nativescript

我想知道如何在堆栈布局中将带有标签 textwrap 的文本居中。

我尝试使用 horizo​​ntalAlignment="center",小文本没问题(例如:"hello"、"test test"),但如果我在标签上使用 textWrap,它就不起作用。 ..

<StackLayout v-for="(text, indexVerse) in texts"
                borderRadius="5" margin="5" padding="15" row="1" col="0" horizontalAlignment="center">

    <Label textWrap="true"
            :text="text.content"
            color="#FFFFFF"
            textAlign="center"
            fontSize="20"/>
</StackLayout>

文字设置在左边,没有居中:

设置文本对齐方式的 属性 如果它在模板上内联,则为 textAlignment;如果您通过 css 设置它,则为 text-align

尝试用 textAlignment 替换 textAlign,如下所示:

<Label textWrap="true"
            :text="text.content"
            color="#FFFFFF"
            textAlignment="center"
            fontSize="20"/>