Nativescript-Vue 移除 iOS ListView 点击颜色

Nativescript-Vue Remove iOS ListView tap color

如何更改列表项上的点击颜色?我的应用程序是一个深色主题,因此当您单击该单元格时会出现白色闪光,这非常难看。我尝试了以下方法:

组件

const ls  = this.$refs.list

ls.itemLoading=(args)=>{
  const cell = args.ios;
  cell.selectionStyle = UITableViewCellSelectionStyle.UITableViewCellSelectionStyleNone;

} 

我还在我的 mounted 方法中尝试过在具有 ListView

的组件上这样做

this.$refs.list 日志:

 _uid: 20,
_isVue: true,
'$options':
{ parent:
{ _uid: 19,
_isVue: true,
'$options': [Object],
_renderProxy: [Object],
_self: [Circular],
'$parent': [Object],
'$root': [Object],
'$children': [Object],
'$refs': [Object],
_watcher: [Object],
_inactive: null,
_directInactive: false,
_isMounted: true,
_isDestroyed: false,
_isBeingDestroyed: false,
_events: [Object],
_hasHookEvent: false,
_vnode: [Object],
_staticTrees: null,
'$vnode': [Object],
'$slots': {},
'$scopedSlots': {},
_c: [Object],
'$createElement': [Object],
'$attrs': [Getter/Setter],
'$listeners': [Getter/Setter],
'$store': [Object],
_watchers: [Object],
_props: [Object],
clearHistory: [Object],
go: [Object],
_data: [Object],
clubs: [<…>

你的代码看起来不错。但是,你只是稍微偏离了。

您正在通过您的要求引用 listview 模块。您需要在 ListView 而不是模块的实例上使用该事件。

因此,在 page/component 的页面事件或 vue 生命周期事件中,您应该从模板中获取 ListView 的实例,然后像您一样使用 itemLoading 事件它。

itemLoading

使用事件绑定

HTML

<ListView ref="listview" @itemLoading="onItemLoading">

JS

onItemLoading: function(args) {
   const cell = args.ios;
   if (cell) {
     cell.selectionStyle = UITableViewCellSelectionStyle.UITableViewCellSelectionStyleNone;
   }
}