开发者社区> 问答> 正文

listView中,头部如果是input的话,listView往下滚至input消失,再滚回去input输入内容会被重置

测试环境
iPhone:10.2.1-iOS
weex_sdk: 0.9.5
qap-cli: 3.0.16
千牛版本: 测试版 5.8.2.1

比如先在input里输入 abc
往下滚至input消失
在回滚至input出现
input输入框已经被重置

'use strict';

import {createElement, Component, render} from 'rax';
import {View, ListView, TextInput} from 'nuke';

class Demo extends Component {
    constructor(props) {
      super(props);

      this.state = {
          dataSource: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
      };
    }

    renderRow = (item) => {
        console.log(1);
        return <View style={{height: 200, width: 750}}>test</View>
    }

    renderHeader = () => {
        return (
            <TextInput style={{width: 750, height: 60, borderWidth: 3}} />
        )
    }
    render() {
        return (
            <View style={styles.container}>
                <ListView
                    style={{width: 750, height: 1200}}
                    renderHeader={this.renderHeader}
                    renderRow={this.renderRow}
                    dataSource={this.state.dataSource}
                />
            </View>
        );
    }
}

const styles = {
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#fff',
    }
};

render(<Demo />);

export default Demo;

有什么办法解决吗?

展开
收起
milo__ 2017-03-06 17:48:51 2466 0
2 条回答
写回答
取消 提交回答
  • 翻译一下楼上的:

    原因是:滚动到下方的时候,input所在的容器被回收,导致数据没了。

    解决办法:1. 你可以找个state 存下这个input 的值

    1. 或者 我们做listview时提供某个cell 不回收的api
    2019-07-17 20:52:33
    赞同 1 展开评论 打赏
  • weex 0.11发版了,有cell 不回收的机制,加上就好了

    2019-07-17 20:52:33
    赞同 1 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载