【发布时间】:2023-03-12 09:17:01
【问题描述】:
我正在尝试通过单击 STORE [<Label>] 将产品添加到购物车。 然后,我正在更改该添加列表的标签颜色。
之后,我尝试通过滚动添加更多产品。自动地,其他一些ListView 列表的标签颜色发生了变化。
我知道这些行为会发生在UITableView 和iOS 中。在NSDictionary 的帮助下,我可以处理这个问题。 Tableview Reusing in iOS
我不知道如何在NativeScript 中处理这个问题
编码
.js
exports.cartColorChange = function(args) {
var lbl = args.object;
lbl.color = "rgb(171, 0, 230)";
};
.xml
<ListView col="0" row="2" items="{{ mySecondItems }}" id="myListVw" itemLoading="listViewItemsLoading" itemTap="secondListViewItemTap" class="list-group" separatorColor="transparent">
<ListView.itemTemplate>
<GridLayout class="listGrid" columns="75,*" rows="*" width="100%" height="90" >
<Label col="0" row="0" class="roundCircle" text="{{ price }}" textWrap="true" />
<StackLayout col="1" row="0" orientation="vertical" verticalAlignment="center">
<Label class="booksubtitle" text="{{ subtitle }}" textWrap="true" id="wow" />
<Label class="bookTitle" text="{{ title }}" textWrap="true" />
<Label class="addCart" text="" textWrap="true" tap="cartColorChange" />
</StackLayout>
</GridLayout>
</ListView.itemTemplate>
</ListView>
.css
Label.addCart{
text-align: right;
color: rgb(220, 220, 220);
margin-right: 15px;
margin-bottom: 0px;
font-size: 15px;
font-family: "FontAwesome";
}
输出:
【问题讨论】:
-
请添加nativescript游乐场演示。
-
我不知道。
-
play.nativescript.com
-
任何帮助@bhavinjalodara
-
请在 play.nativescript.com 上复制演示并发布链接。
标签: javascript xml nativescript