【发布时间】:2018-07-27 10:01:48
【问题描述】:
我在使用 react-native-textinput-effects 时出错。 这是我的错误信息:
fontFamily 'Arial' 不是系统字体,尚未加载 通过 Expo.Font.loadAsync。 - node_modules\react-native\Libraries\Renderer\ReactNativeRenderer-dev.js:3382:38 在差异属性中 - 如果您打算使用系统字体,请确保您输入的名称正确且受您的设备操作系统支持。
- 如果这是自定义字体,请务必使用 Expo.Font.loadAsync 加载它。
- node_modules\expo\src\Font.js:34:10 in processFontFamily
- node_modules\react-native\Libraries\Renderer\ReactNativeRenderer-dev.js:3382:38 在 diffProperties 中
- ...来自框架内部的另外 30 个堆栈帧
这是我的代码:
import React, { Component } from 'react'
import { StyleSheet, View, Text, TextInput, Image, TouchableOpacity } from 'react-native'
import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
import { Font } from "expo";
import { Fumi} from 'react-native-textinput-effects';
class Login extends React.Component {
render() {
return (
<View style={styles.main_container}>
<View style={styles.subview_container}>
<View style={[styles.card2, { backgroundColor: '#a9ceca' }]}>
<Text style={styles.title}>Fumi</Text>
<Fumi
label={'Course Name'}
labelStyle={{ color: '#a3a3a3' }}
inputStyle={{ color: '#f95a25' }}
iconClass={FontAwesomeIcon}
iconName={'university'}
iconColor={'#f95a25'}
iconSize={15}
/>
<Fumi
style={styles.input}
label={'Degree'}
iconClass={FontAwesomeIcon}
iconName={'graduation-cap'}
iconColor={'#77116a'}
/>
</View>
</View>
</View>
)
}
}
const styles = StyleSheet.create({
main_container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
borderColor: '#555500',
},
subview_container: {
},
card2: {
padding: 16,
},
input: {
marginTop: 4,
},
title: {
paddingBottom: 16,
textAlign: 'center',
color: '#404d5b',
fontSize: 20,
fontWeight: 'bold',
opacity: 0.8,
}
})
export default Login
我尝试使用此代码加载 Arial 字体但没有成功:
componentDidMount() {
Font.loadAsync({
'Arial': require('./assets/fonts/Arial.ttf'),
});
}
你能帮帮我吗?
【问题讨论】:
-
德克萨斯州。我删除 fontFamily: 'Arial',on Fumi.js
标签: android react-native