素材牛VIP会员
React Native在真机上运行报错提示view config not found for name view?
 lo***68  分类:JavaScript  人气:2110  回帖:1  发布于6年前 收藏

在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);

下面是报错信息截图:

讨论这个帖子(1)垃圾回帖将一律封号处理……

Lv4 码徒
lh***81 产品经理 6年前#1

是不是应该写成import Index from './app/pages/Index';

 文明上网,理性发言!   😉 阿里云幸运券,戳我领取