小编Jos*_*aez的帖子

console.error: "fontFamily "Roboto_medium" 不是系统字体,还没有通过 Font.loadAsync 加载

在使用 import Native Base 时(因为它来了),我遇到了问题,因为屏幕中显示了字体错误。如果您单击关闭它会消失,但用户无法在每次加载文本时看到它。¿是否有解决字体问题的正确方法?

这个官方文档说要这样做:

// At the top of your file
import { Font } from 'expo';
import { Ionicons } from '@expo/vector-icons';

// Later on in your component
async componentDidMount() {
  await Font.loadAsync({
    'Roboto': require('native-base/Fonts/Roboto.ttf'),
    'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
    ...Ionicons.font,
  });
}
Run Code Online (Sandbox Code Playgroud)

但它没有用。这是我的代码:

import React, { Component } from 'react';
import { View, } from "react-native";
import { Button, Text } from 'native-base';

export default class MyComponent extends Component {

  render() {

        return (
                 <View>
                     <Button>
                       <Text>Click …
Run Code Online (Sandbox Code Playgroud)

react-native native-base expo

3
推荐指数
3
解决办法
2万
查看次数

标签 统计

expo ×1

native-base ×1

react-native ×1