1

我对原生、nativebase 和 Exponent 的反应还很陌生。不幸的是,我什至无法显示简单的组件。我花了大约 6 个多小时对 nativebase 文档中的简单教程组件进行故障排除。我觉得我只是缺少一些基本的东西,我真的很感激能伸出援助之手。

这就是我正在做的事情:使用 Exponent XDE 运行我的项目。根据文档安装了nativebase,此时没有错误。

main.js

'use strict';
import React, { Component } from 'react';
import {
  AppRegistry,
} from 'react-native';
import { Container } from 'native-base';
import { CardImageExample } from './component/card.js';



AppRegistry.registerComponent('main', () => CardImageExample);

卡片.js

import React, { Component, Image } from 'react';
import { Container, Content, Card, CardItem, Thumbnail, Text, Icon } from 'native-base';

class CardImageExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Card>
                        <CardItem>
                            <Thumbnail source={require('./img/penguin-icon.png')} />
                            <Text>Instrumental Songs</Text>
                            <Text note>Guitar</Text>
                        </CardItem>

                        <CardItem>                        
                            <Image style={{ resizeMode: 'cover' }} source={require('./img/penguin.jpg')} /> 
                        </CardItem>

                        <CardItem>
                            <Icon name='ios-musical-notes' style={{color : '#ED4A6A'}} />
                            <Text>Listen now</Text>                        
                        </CardItem>
                   </Card>
                </Content>
            </Container>
        );
    }
}
export default CardImageExample;

当前错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义

我只是完全不知道从哪里开始。谢谢。

4

2 回答 2

0

您必须像这样注册您的应用程序Exponent.registerRootComponent(App)。如果您使用的是指数。示例:https ://github.com/exponent/nativebase-example

于 2017-02-21T16:56:02.950 回答
0

你的 main.js 应该喜欢一些东西

import * as Exponent from 'exponent';
import React from 'react';
import First from './src/app';
import { Container, Header, Title, Content, Button, Left, Right, Body,Icon, Separator } from 'native-base';

class App extends React.Component {
 render() {
    return <First / > ;
 }
}
Exponent.registerRootComponent(App);
于 2017-02-21T17:16:21.200 回答