We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const onClick = () => { console.log("onClick");} const Row = React.memo(({ index, style, data }) => { return ( <View className={index % 2 ? 'ListItemOdd' : 'ListItemEven'} style={style} onClick={onClick}> Row {index} ); })
function buildData (offset = 0) { return Array(100).fill(0).map((_, i) => i offset); }
export default class Index extends Component { state = { data: buildData(0), }
loading = false
listReachBottom() { Taro.showLoading() // 如果 loading 与视图相关,那它就应该放在 this.state 里 // 我们这里使用的是一个同步的 API 调用 loading,所以不需要 this.loading = true setTimeout(() => { const { data } = this.state this.setState({ data: data.concat(buildData(data.length)) }, () => { this.loading = false; Taro.hideLoading() }) }, 1000) }
this.state
render() { const { data } = this.state const dataLen = data.length const itemSize = 100 return ( <VirtualList className='List' height={500} itemData={data} itemCount={dataLen} itemSize={itemSize} width='100%' onScroll={({ scrollDirection, scrollOffset }) => { if ( // 避免重复加载数据 !this.loading && // 只有往前滚动我们才触发 scrollDirection === 'forward' && // 5 = (列表高度 / 单项列表高度) // 100 = 滚动提前加载量,可根据样式情况调整 scrollOffset > ((dataLen - 5) * itemSize 100) ) { this.listReachBottom() } }} > {Row} ); } }
期望滚动后,onClick还是能执行。
The text was updated successfully, but these errors were encountered:
在每次生成的css中,多了一个pointer-events: none;
Sorry, something went wrong.
#7140
No branches or pull requests
这个特性解决了什么问题?
const onClick = () => { console.log("onClick");}
const Row = React.memo(({ index, style, data }) => {
return (
<View className={index % 2 ? 'ListItemOdd' : 'ListItemEven'} style={style} onClick={onClick}>
Row {index}
);
})
function buildData (offset = 0) {
return Array(100).fill(0).map((_, i) => i offset);
}
export default class Index extends Component {
state = {
data: buildData(0),
}
loading = false
listReachBottom() {
Taro.showLoading()
// 如果 loading 与视图相关,那它就应该放在
this.state
里// 我们这里使用的是一个同步的 API 调用 loading,所以不需要
this.loading = true
setTimeout(() => {
const { data } = this.state
this.setState({
data: data.concat(buildData(data.length))
}, () => {
this.loading = false;
Taro.hideLoading()
})
}, 1000)
}
render() {
const { data } = this.state
const dataLen = data.length
const itemSize = 100
return (
<VirtualList
className='List'
height={500}
itemData={data}
itemCount={dataLen}
itemSize={itemSize}
width='100%'
onScroll={({ scrollDirection, scrollOffset }) => {
if (
// 避免重复加载数据
!this.loading &&
// 只有往前滚动我们才触发
scrollDirection === 'forward' &&
// 5 = (列表高度 / 单项列表高度)
// 100 = 滚动提前加载量,可根据样式情况调整
scrollOffset > ((dataLen - 5) * itemSize 100)
) {
this.listReachBottom()
}
}}
>
{Row}
);
}
}
这个 API 长什么样?
期望滚动后,onClick还是能执行。
The text was updated successfully, but these errors were encountered: