在这里,我使用的是基于本地的最新版本,并使用所有方法道具,但我的图标仍未出现在标题中
import React, { Component } from "react";
import {
View,
Text,
StyleSheet
} from "react-native";
import {Header,Icon} from 'native-base'
class HomeScreen extends Component {
static navigationOptions = { header: null }
render() {
return (
<View style={{flex:1,backgroundColor:'#3q455c',width:"100%"}}>
<Header
placement="left"
leftComponent={{ icon: 'menu', color: 'white' }}
centerComponent={{ text: 'MY TITLE', style: { color: 'white' } }}
rightComponent={{ icon: 'home', color: 'white' }}
/>
</View>
);
}}
export default HomeScreen;
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
}
});
Run Code Online (Sandbox Code Playgroud)
小智 14
为了解决这个问题,我做到了:
react-native link
react-native run-android
Run Code Online (Sandbox Code Playgroud)
和显示的图标。
安装 react-native-vector-icons
npm install --save react-native-vector-icons
Run Code Online (Sandbox Code Playgroud)
IOS:
react-native link react-native-vector-icons
Run Code Online (Sandbox Code Playgroud)
安卓:
编辑 android/app/build.gradle (不是 android/build.gradle )并添加以下内容:
project.ext.vectoricons = [
iconFontNames: [ 'MaterialIcons.ttf', 'EvilIcons.ttf' ] // Name of the font files you want to copy]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
Run Code Online (Sandbox Code Playgroud)
和使用:
<Icon
type="MaterialIcons"
name="menu"
/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2828 次 |
| 最近记录: |