![](/img/trans.png)
[英]I can't use Expo-av together with react-native-track-player in an Expo React Native app
[英]I got a warning and couldn't use FontAwesome in React Native on Expo
现在我正在尝试在Expo上的React Native App中使用FontAwesome。
我遵循了有关如何通过Expo on Expo文档使用自定义字体的流程,但是这些图标无法工作,并且我看不到任何字体。
幸运的是我没有任何错误,只有警告。
这是我的下面的代码。 请教我。
谢谢。
import { Font } from 'expo';
import { fontAwesome } from '../../assets/fonts/fa-solid-900.ttf';
class Help extends React.Component {
state = {
fontLoaded: false,
};
async componentDidMount() {
await Font.loadAsync({
FontAwesome: fontAwesome,
});
this.setState({ fontLoaded: true });
}
renderHelpLists() {
return HelpLists.map((value, index) => {
return (
<TouchableOpacity
key={index}
style={styles.helpListsBox}
>
<Text style={styles.helpListText}>
{value.name}
</Text>
{
this.state.fontLoaded ? (
<Text style={styles.rightIcon}>
{'\f054'}
</Text>
) : null
}
</TouchableOpacity>
);
});
}
const styles=Stylesheet.create({
rightIcon: {
fontFamily: 'FontAwesome',
},
})
我还不熟悉通过在React Native中导入TTF文件来使用Font Awesome。
但是,您可以尝试使用Font Awesome React Native组件吗?
我用来自'react-native-vector-icons / FonteAwesome'的导入图标解决了这个问题。
但是我不确定如何使用Expo-Icons。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.