【发布时间】:2020-03-06 06:23:38
【问题描述】:
我是反应原生的初学者,我尝试构建非常基本的应用程序,但出现以下错误
Invariant Violation: View config not found for name div. Make sure to start component names with a capital letter.
此错误位于: 在 div 中(由 View 创建) 在视图中(由 ScrollView 创建) 在 div 中(由 View 创建) 在视图中(由 ScrollViewBase 创建) 在 ScrollViewBase(由 ScrollView 创建) 在 ScrollView 中(在 Horizontal.js:8 处) 在水平(在 App.js:12) 在 RCTView 中(在 View.js:45) 在视图中(在 App.js:11) 在应用程序中(在 withExpoRoot.js:20) 在 RootErrorBoundary 中(在 withExpoRoot.js:19) 在 ExpoRootComponent 中(在 renderApplication.js:35) 在 RCTView 中(在 View.js:45) 在视图中(在 AppContainer.js:98) 在 RCTView 中(在 View.js:45) 在视图中(在 AppContainer.js:115) 在 AppContainer 中(在 renderApplication.js:34 处) 得到
下面是我的源码
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import {ScrollView} from "react-native-web";
export default class Horizontal extends React.Component{
render() {
return (
<ScrollView>
<View>
<Text style={styles.innerText}>
Welcome to LCOs
</Text>
</View>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
container: {
},
outer: {
},
innerText:{},
});
这是我的主要课程
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Red from './component/Red';
import Green from "./component/Green";
import Blue from "./component/Blue";
import Horizontal from "./component/Horizontal";
export default class App extends React.Component{
render() {
return (
<View style={styles.container}>
<Horizontal/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent:'center',
flexDirection:'row'
},
});
此错误的原因是什么,我该如何解决?
【问题讨论】:
-
为什么要从 react-native-web 实现 ScrollView?你能把它从“react-native”改过来吗?
标签: react-native