在rn中自己写了一个小页面在真机运行报错:Invariant Violation:view config not found for name view
下面是我的代码:
import React,{ Component } from 'react';
import {
View,
Text,
TextInput,
Image,
StyleSheet
} from 'react-native';
export default class Index extends Component{
render(){
return (
<View style={styles.container}>
<View style={styles.search}>
<TextInput placeholder="请输入使用场所或账号名称" />
<Text>搜索</Text>
</View>
<View style={styles.category}>
<view style={styles.categoryList}>
<Image source={require('../images/all.png')} />
<Text>全部</Text>
</view>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container:{
padding:20
},
search:{
flex:1,
flexDirection: 'column'
},
category:{
flex:1,
flexDirection: 'column'
},
categoryList:{
flex:1,
flexDirection: 'row'
}
});
我实在index.js中直接import我的代码的,如下:
import { AppRegistry } from 'react-native';
// import App from './App';
import App from './app/pages/Index';
AppRegistry.registerComponent('PdBox', () => App);
下面是报错信息截图:
你这里的"view"手写字母要大写,应该是<View></View>