javascript - TypeError: undefined is not an object (evaluate '_reactNative.Stylesheet.create') in react native
问题描述
我正在用 react native 制作一个项目,并且我已经安装了它的所有依赖项,但是当我运行它显示的代码时
TypeError: undefined is not an object (evaluating '_reactNative.Stylesheet.create')
连同下面的这个
node_modules/react-native/Libraries/LogBox/LogBox.js:148:8 in registerError
node_modules/react-native/Libraries/LogBox/LogBox.js:59:8 in errorImpl
node_modules/react-native/Libraries/LogBox/LogBox.js:33:4 in console.error
node_modules/expo/build/environment/react-native-logs.fx.js:27:4 错误
node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
ErrorUtils.setGlobalHandler$argument_0 中的 node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:9:32
tryCatch 中的 node_modules/regenerator-runtime/runtime.js:63:36
node_modules/regenerator-runtime/runtime.js:293:29 在调用
tryCatch 中的 node_modules/regenerator-runtime/runtime.js:63:36
调用中的 node_modules/regenerator-runtime/runtime.js:154:27
PromiseImpl.resolve.then$argument_0 中的 node_modules/regenerator-runtime/runtime.js:164:18
tryCallOne 中的 node_modules/react-native/node_modules/promise/setimediate/core.js:37:13
setImmediate$argument_0 中的 node_modules/react-native/node_modules/promise/setimmediate/core.js:123:24
_callTimer 中的 node_modules/react-native/Libraries/Core/Timers/JSTimers.js:130:14
_callImmediatesPass 中的 node_modules/react-native/Libraries/Core/Timers/JSTimers.js:181:14
node_modules/react-native/Libraries/Core/Timers/JSTimers.js:441:30 in callImmediates
__callImmedates 中的 node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:387:6
__guard$argument_0 中的 node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:135:6
__guard 中的 node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:364:10
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:134:4 在flushedQueue
- [本机代码]:flushedQueue 中的 null
- [本机代码]:invokeCallbackAndReturnFlushedQueue 中的 null
起初它谈到了我修复的一个函数,但我不明白它在哪里引用未定义的对象,如果有人能找到它正在谈论的文件或函数,那就太好了。
解决方案
请尝试这样的事情
const styles = StyleSheet.create({
_container: {
flex: 1,
backgroundColor: 'blue',
alignItems: 'center',
justifyContent: 'center'
},
get container() {
return this._container;
},
set container(value) {
this._container = value;
},
});
推荐阅读
- python-3.x - numpy 库导入不可用的错误?
- jquery - jquery ajax 快速点击时加载中断页面
- python - 使用 Python 进行网页抓取:如何按像素滚动到视图中?
- ios - 用几何放置 SCNNode
- php - 更新查询不起作用,但代码似乎很好
- javascript - 问题无法使用 mongodb (ejs) 在 node.js 中发布
- wolfram-mathematica - 积分变化变量下标
- python - 如何在 python 中使用带有 file.edf 的 ICA 方法来识别噪声分量?
- c# - moving every int in the array one place backwards
- java - 如何为调用其他私有方法的私有 void 方法编写单元测试?