1、react-native中expo的真机测试字体不加载的坑

时间:2023-03-09 00:00:55
1、react-native中expo的真机测试字体不加载的坑

native-base的字体问题Roboto_medium

1、react-native中expo的真机测试字体不加载的坑

把native-base中的Fonts文件夹放到项目的根目录.

import {Font,AppLoading} from 'expo';
import {Root} from 'native-base'; export default class App extends React.Component {
constructor(){
super();
this.state={
loading:true
}
}
async componentWillMount() {
await Expo.Font.loadAsync({
'Roboto': require('./Fonts/Roboto.ttf'),
'Roboto_medium': require('./Fonts/Roboto_medium.ttf'),
});
this.setState({
loading:false
}); } render() {
if(this.state.loading){
return (
<Root>
<AppLoading/>
</Root>
)
} return ()
}