我试图在 ReactNative 中声明一个静态变量,但当我收到此错误消息时,我似乎无法让它工作:
SyntaxError: /Users/vikaton/Desktop/iComeUp/src/components/LoginForm.js: static is a reserved word in strict mode (74:4)
9:37:20 PM: 72 |
9:37:20 PM: 73 | render() {
9:37:20 PM: > 74 | static navigationOptions = {
9:37:20 PM: | ^
9:37:20 PM: 75 | header: null
9:37:20 PM: 76 | };
9:37:20 PM: 77 | const { navigate } = this.props.navigation // fontFamily: 'heiti TC'
我在代码顶部添加了 'use strict';
但仍然收到错误消息。
有什么指点吗?
最佳答案
您希望静态位于 render
方法之外,而不是内部
static navigationOptions = { header: null }
render() {
const { navigate } = this.props.navigation
...
}
关于javascript - static 是严格模式的保留关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48180866/