我对原生、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;
当前错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义
我只是完全不知道从哪里开始。谢谢。