【发布时间】:2017-04-24 16:39:12
【问题描述】:
我在将多个 NativesScript 变量显示为句子时遇到问题。
我有 5 个变量:
string1 = 'Hello';
string2 = 'John';
string3 = 'how are you? how are you? how are you?';
string4 = 'Button';
string5 = 'Test Test Test Test Test Test Test Test Test Test Test Test
Test Test Test Test';
我正在努力实现:
Hello John how are you? how are you? how are you? Button Test Test Test
Test Test Test Test Test Test Test Test Test Test Test Test Test
string2 和 string4 应该是可点击的。我用 Span 尝试了 FormattedString,但 span 不能有任何事件,所以它不可点击。我也尝试过 GridLayout ,但它按列或按行分隔(每个变量都从新行开始)。我还尝试了水平方向的 StackLayout,但它没有正确换行并且没有转到另一行。
任何帮助将不胜感激。
已编辑:
在其他一些论坛的帮助下,我的新问题是使用 WrapLayout:
<GridLayout columns="auto,*,auto" >
<Label col="0" text="Testing "></Label>
<WrapLayout col="1">
<Label text="Hello" ></Label>
<Label text="John"></Label>
<Label text="how are you? how are you? how are you?"></Label>
<Label text="Button Button Button"></Label>
<Label text="Test Test Test Test Test Test Test Test Test Test Test
Test Test Test Test Test"></Label>
</WrapLayout>
<Label col="2" text="Test2"></Label>
结果:
HelloJohn
how are you? how are you? how are you?
Button Button Button
Test Test Test Test Test Test Test Test
Test Test Test Test Test Test Test Test
我想问你好吗?你好吗?你好吗?'转到第一行,“测试”与“按钮”在同一行开始?
这样
HelloJohnhow are you? how are you? how are you?
Button Button ButtonTest Test Test Test Test Test Test Test
Test Test Test Test Test Test Test Test
谢谢
已编辑:
我试过了
<GridLayout columns="auto,*,auto" class="post-top-wrapper">
<Label col="0" text="Testing "></Label>
<FlexboxLayout col="1" flexWrap="wrap">
<Label text="Hello" ></Label>
<Label text="John"></Label>
<Label text="how are you? how are you? how are you?"></Label>
<Label text="Button Button Button"></Label>
<Label text="Test Test Test Test Test Test Test Test Test Test Test
Test Test Test Test Test"></Label>
</FlexboxLayout>
<Label col="2" text="Test2"></Label>
我得到与上面提到的相同的结果。短字符串没有问题,但是长字符串(不适合一行)不是从同一行开始,而是从新的一行开始。
已编辑:
我已经缩小了问题的范围:两个长字符串不能在同一行开始。
【问题讨论】:
-
你试过
<a>标签吗? -
@mast3rd3mon 我认为您不能在 nativeScript 中使用 标签,如果我错了,请提供示例或链接。谢谢
-
你不能,我刚刚检查过,但你可以有带有点击事件的标签
标签: nativescript angular2-nativescript