gpt4 book ai didi

javascript - 在 NativeScript 中创建可点击的图像

转载 作者:行者123 更新时间:2023-12-01 03:11:07 28 4
gpt4 key购买 nike

我正在寻找一种在 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>

甚至没有显示图像。我做错了什么?

编辑:更新格式

最佳答案

根据文档,您只需使用 on("event",implementation) 方法即可设置 touch 监听器。

https://docs.nativescript.org/ui/gestures#touch

因此,您的图像在 xml 中将具有 (tap) 属性,或者您可以按照上面提到的方式设置 onTap 事件。

并且 Image 不是复合 View (布局),因此它不应该在其中包含按钮元素。

关于javascript - 在 NativeScript 中创建可点击的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45839970/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com