react-native-sortable-listview无法拖拽排序
来源:5-10 Popular(最热)模块的标签排序功能实现-1
 
			Leonard_
2018-07-14
render(){
    return(
        <View style={styles.container}>
            <NavigationBar
                title='我的'
                style={{backgroundColor:'#6495ED'}}
            />
            <SortableListView
                style={{flex: 1}}
                data={this.state.checkedArray}
                order={Object.keys(this.state.checkedArray)}
                onRowMoved={(e) => {
                    this.state.checkedArray.splice(e.to, 0, this.state.checkedArray.splice(e.from, 1)[0]);
                    this.forceUpdate()
                }}
                renderRow={row => <SortCell data={row} {...this.props}/>}
            />
        </View>
    )
}
拖拽时整个列表上下移动,无法对标签就行拖拽排序

2回答
- 
				  zxzzhao 2019-02-12 这个问题解决了吗? 遇到了一样的问题 00
- 
				  CrazyCodeBoy 2018-07-15 上述代码是OK的,问题出在SortCell,你查下SortCell的代码看是不是比课程中所讲的少了个TouchableHighlight呢: class SortCell extends Component { render() { return <TouchableHighlight underlayColor={'#eee'} style={this.props.data.checked ? styles.item : styles.hidden} {...this.props.sortHandlers}> <View style={{marginLeft: 10, flexDirection: 'row'}}> <Image source={require('./img/ic_sort.png')} resizeMode='stretch' style={[{ opacity: 1, width: 16, height: 16, marginRight: 10, },this.props.theme.styles.tabBarSelectedIcon]}/> <Text>{this.props.data.name}</Text> </View> </TouchableHighlight> } }之所以会出现拖动整个列表滑动,是当SortCell不响应Touch时,Touch时间会被列表接收,所以拖动行会整个列表都跟着滑动; 022018-07-16
相似问题
 
						