【发布时间】:2017-08-23 12:38:36
【问题描述】:
我正在寻找一种在 NativeScript 中设置可点击图像的方法。我计划将 5 个图像彼此相邻设置,并且每当单击一个图像时,左侧的图像应该更改其值。
我尝试了什么:
<Label col="0" row="0" class="text-details segment-content" [text]="'RATING_AVG'|translate">
</Label>
<Label col="1" row="0" class="text-details segment-content">
<GridLayout columns="*,*,*,*,*" rows="*">
<Image src="~/pages/filmdetails/Stern-outline-10.jpg" col="0" row="0">
<Button (onTap)="logTap()">
</Button>
</Image>
<Image src="~/pages/filmdetails/Stern-outline-10.jpg" col="1" row="0">
<Button (onTap)="logTap()">
</Button>
</Image>
<Image src="~/pages/filmdetails/Stern-outline-10.jpg" col="2" row="0">
<Button (onTap)="logTap()">
</Button>
</Image>
<Image src="~/pages/filmdetails/Stern-outline-10.jpg" col="3" row="0">
<Button (onTap)="logTap()">
</Button>
</Image>
<Image src="~/pages/filmdetails/Stern-outline-10.jpg" col="4" row="0">
<Button (onTap)="logTap()">
</Button>
</Image>
</GridLayout>
</Label>
甚至没有显示图像。我做错什么了?
编辑:更新格式
【问题讨论】:
-
我从来没有使用过 nativescript,但嵌套看起来很糟糕。您在
Label中有一个Gridlayout,而您的三个Images 不在五列Gridlayout内。 -
根据this 应该是
<Button (tap)="logTap()"> -
哦,我显然错过了该图像的一些格式 - onTap 功能有效,我已经用另一个按钮进行了测试。不过谢谢你的回复! :)
标签: javascript html typescript nativescript