我得到的错误是:使用本机base时为You started loading 'Roboto_medium', but used it before it finished loading.

enter image description here

我已经按照官方页面上的说明做了.

要创建react-native 应用程序,我使用create-react-native-app.

应用程序.js

export default class App extends React.Component {

async componentWillMount() {
  await Expo.Font.loadAsync({
  'Roboto': require('native-base/Fonts/Roboto.ttf'),
  'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
  'Ionicons': require('@expo/vector-icons/fonts/Ionicons.ttf'),
 });
}

 render() {
   return (
    <Container>
      <StatusBar hidden={true} />

    <Button>
      <Text>
        Button
      </Text>
    </Button>

    <ListaItens />
    </Container>
  );
}
} 

推荐答案

你需要等待字体加载.你可以这样做

import React from "react";
import { StatusBar } from "react-native";
import { Container, Button, text, ListItem, Text } from "native-base";
import Expo from "expo";

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = { loading: true };
  }

  async componentWillMount() {
    await Expo.Font.loadAsync({
      Roboto: require("native-base/Fonts/Roboto.ttf"),
      Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf"),
      Ionicons: require("@expo/vector-icons/fonts/Ionicons.ttf"),
    });
    this.setState({ loading: false });
  }

  render() {
    if (this.state.loading) {
      return <Expo.AppLoading />;
    }
    return (
      <Container>
        <StatusBar hidden={true} />

        <Button>
          <Text>Button</Text>
        </Button>

        <ListItem />
      </Container>
    );
  }
}

React-native相关问答推荐

单击时更改ToucheableOpacity colored颜色 不起作用

Touchabble 不透明度不工作-react 本机

'未能找到 React 根视图的片段' React Native Android RNScreens

React Native Ios错误 - ENOENT:no such file or directory, uv_cwd (null)

react-native 签名 [AppName]Tests 需要开发团队 ios

React Native:约束 Animated.Value

TouchableOpacity 作为 ListView 中的 Item 仅在 TextInput 失go 焦点后做出响应

当组件在react-native 中重新呈现时,动态不透明度不会改变

React Native 检测点击 View

如何将本地文本文件加载到 React Native Project 中的字符串变量中?

React Native 无法运行堆栈跟踪

等待模块失效的超时

删除某些屏幕的顶部导航栏

horizontal水平 FlatList 前后的间距

对未计算文件的本机Bundle sha-1 做出react(无法从assets index.android.bundle 加载脚本)

react-native:多色文本视图

如何为 TouchableOpacity 组件创建禁用样式?

React Native <>(空)组件到底是什么

React Native:如何动态更改

如何在 React Native 中强制禁用 iOS 暗模式