gpt4 book ai didi

javascript - ListView.setClickable() 不起作用。 (Nativescript-Vue)

转载 作者:行者123 更新时间:2023-12-02 23:39:17 25 4
gpt4 key购买 nike

我正在编写 Nativescript-Vue 应用程序。

我有一个包含两个子组件的组件。因此,当我点击第二个按钮中的按钮时,我需要禁用第一个按钮中的 ListView 的滚动。

所以我通过“ref=”获取了 ListView 元素并将其放入商店(Vuex)

<ListView ref="listViewEl" ></ListView>
...
mounted() {
store.commit('putElInStore', this.$refs.listViewEl)
}

...

putElInStore(state, element) {
state.listViewEl = element
}

当我点击第二个子组件中的按钮时,我需要禁用 ListView 滚动。所以我使用 store.commit 来做到这一点:

<Button @tap="disableListViewScrolling"></Button>
...
disableListViewScrolling() {
store.commit('disableScrolling')
}

...

disableScrolling(state) {
state.listViewEl.nativeView.android.setClickable(false)
}

所以在这种情况下我没有收到任何错误,但根本没有任何反应。这根本行不通。

我还尝试使用 setEnabled(false) 代替。它有效,但不正确。

我想念什么?我的错误在哪里?

提前致谢。

最佳答案

不需要将元素存储在 Vuex 中。如果没有完整的代码,我将为您提供如何执行此操作的总体布局。

<Parent>
<childOne ref="listViewChild"></childOne>
<childTwo @disableButtonTapped="$refs.listViewChild.disableClick()"></childTwo>
</Parent>
<childOne> 
<ListView ref="list"></ListView>
</childOne>

<script>
export defaults {
methods: {
disableClick () {
this.$refs.list.nativeView.android.setClickable(false)
}
}
}
</script>
<childTwo> 
<Button @tap="$emit('disableButtonTapped')"></Button>
</childTwo>

显然这段代码并不准确。

关于javascript - ListView.setClickable() 不起作用。 (Nativescript-Vue),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56146762/

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