【发布时间】:2019-02-18 23:54:11
【问题描述】:
我是 React Native 的新手,我想使用 react-native-material-bottom-navigation。我发现了一些与此相关的其他问题,但无法为我提供一些启示。
我使用 npm 安装了依赖项并运行命令 react-native link 然后我执行了 react-native run-android
这是我在 App.js
中的代码import React, { Component } from 'react';
import BottomNavigation, {
FullTab
} from 'react-native-material-bottom-navigation'
import {
View,
Icon
} from 'react-native';
export default class App extends Component {
tabs = [
{
key: 'games',
icon: 'gamepad-variant',
label: 'Games',
barColor: '#388E3C',
pressColor: 'rgba(255, 255, 255, 0.16)'
},
{
key: 'movies-tv',
icon: 'movie',
label: 'Movies & TV',
barColor: '#B71C1C',
pressColor: 'rgba(255, 255, 255, 0.16)'
},
{
key: 'music',
icon: 'music-note',
label: 'Music',
barColor: '#E64A19',
pressColor: 'rgba(255, 255, 255, 0.16)'
}
]
renderIcon = icon => ({ isActive }) => (
<Icon size={24} color="white" name={icon} />
)
renderTab = ({ tab, isActive }) => (
<FullTab
isActive={isActive}
key={tab.key}
label={tab.label}
renderIcon={this.renderIcon(tab.icon)}
/>
)
render() {
return (
<View style={{ flex: 1 }}>
<View style={{ flex: 1 }}>
{/* Your screen contents depending on current tab. */}
</View>
<BottomNavigation
onTabPress={newTab => this.setState({ activeTab: newTab.key })}
renderTab={this.renderTab}
tabs={this.tabs}
/>
</View>
)
}
}
这是我的环境设置
Environment:
OS: Linux 4.13
Node: 8.11.3
Yarn: 1.9.4
npm: 5.6.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4 => 0.55.4
如果有人可以提供帮助,我们将不胜感激。 提前致谢。
【问题讨论】:
标签: javascript android reactjs react-native