6-17 RN 里面提交评论表单 :提交评论是出错

来源:

poooocket

2016-11-19

1、button 不能用  可能是不兼容,用TouchableOpacity

<TouchableOpacity style={styles.button} onPress={this._submit}>

                <Text style={styles.buttonText}>评论</Text>

</TouchableOpacity>

提交后出错:

YellowBox.js:69 Possible Unhandled Promise Rejection (id: 0):

flase is not defined

ReferenceError: flase is not defined

    at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:112834:23

    at tryCallOne (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:26225:8)

    at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:26311:9

    at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:9158:49

    at Object.callTimer (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:8770:1)

    at Object.callImmediatesPass (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:8874:19)

    at Object.callImmediates (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:8889:25)

    at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7630:43

    at guard (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7513:1)

    at MessageQueue.__callImmediates (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7630:1)

2、修改  onPress={this._submit.bind(this)  后还是会有错误

<TouchableOpacity style={styles.button} onPress={this._submit.bind(this)}>

                <Text style={styles.buttonText}>评论</Text>

</TouchableOpacity>

报错:

ExceptionsManager.js:82 Warning: bind(): You are binding a component method to the component. React does this for you automatically in a high-performance way, so you can safely remove this call. See Detail

写回答

2回答

Scott

2016-11-19

另外一个 bind 的是不是你用的 React 版本还是老的,所以这样写反而不兼容了,你参考下补录的这一章,看能不能升级到一个较新的版本

0
1
poooocket
非常感谢!
2016-11-20
共1条回复

Scott

2016-11-19

flase 是不是拼错了,应该是 false

0
0

贯穿全栈React Native开发App

全面掌握React Native技术,不止步前端开发,让你移动领域大放光彩

946 学习 · 385 问题

查看课程