【问题标题】:(SOLVED) TypeError: undefined is not an object (evaluating 'y.Font.isLoaded')(已解决)TypeError:未定义不是对象(评估'y.Font.isLoaded')
【发布时间】:2019-10-14 12:52:20
【问题描述】:

我正在学习 handlebarlabs 的货币转换器应用课程。我正在尝试通过从 @expo/vector-icons 导入 Ionicons 来将图标添加到我的 ScrollView ListItem。

谁能指导我做错了什么?

以下是我在课程笔记中的代码:

import React, { Component } from 'react';
import { ScrollView, StatusBar, Platform } from 'react-native';
import { Ionicons } from '@expo/vector-icons';

import { ListItem, Separator } from '../components/List';

const ICON_PREFIX = Platform.OS === 'ios' ? 'ios' : 'md';
const ICON_COLOR = '#868686';
const ICON_SIZE = 23;

class Options extends Component {
    handleThemesPress = () => {
        console.log('Press Themes');
    }

    handleSitePress = () => {
        console.log('Site Press');
    }

    render() {
        return (
            <ScrollView>
                <StatusBar translucent={false} barStyle={"default"} />
                <ListItem 
                    text="Themes"
                    onPress={this.handleThemesPress}
                    customIcon={
                        <Ionicons name={`${ICON_PREFIX}-arrow-forward`} size={ICON_SIZE} color={ICON_COLOR} />
                    }
                />
                <Separator/>
                <ListItem 
                    text="Fixer.io"
                    onPress={this.handleSitePress}
                    customIcon={
                        <Ionicons name={`${ICON_PREFIX}-link`} size={ICON_SIZE} color={ICON_COLOR} />
                    }
                />

                <Separator/>
            </ScrollView>
        );
    }
}

export default Options;

以下是我得到的错误:

TypeError: undefined is not an object (evaluating 'y.Font.isLoaded')
This error is located at:
   in p
   in RCTView
   in RCTView
   in TouchableHighlight
   in f
   in RCTScrollContentView
   in RCTScrollView
   in u
   in l
   in Unknown
   in v
   in RCTView
   in RCTView
   in c

更新: 在@Oleg 的回答之后,我已经在 SDK 35.0.0 上,但似乎以前的更新没有正确完成。重新安装最新的 SDK 即可解决此问题。谢谢!

【问题讨论】:

  • 如果您的 Expo SDK 已过时,请尝试将其更新到最新版本。查看此链接以进行更新:docs.expo.io/versions/latest 希望对您有所帮助

标签: react-native expo mobile-application


【解决方案1】:

我通过重用您发布的有问题的代码,使用 Ionic Example 创建了零食。 请检查您项目中 package.json 和 expo sdk 中的版本。 https://snack.expo.io/@djalik/ionicons

【讨论】:

  • 我已经使用了 SDK 35,但重新安装 SDK 可以解决问题。谢谢
猜你喜欢
  • 2021-12-17
  • 2021-12-01
  • 2019-11-16
  • 2020-02-09
  • 2019-12-07
  • 2022-01-01
  • 2019-01-20
  • 2014-06-13
  • 2021-07-24
相关资源
最近更新 更多