【问题标题】:Fonts and images cannot be resolved after expo ejectexpo 弹出后无法解析字体和图像
【发布时间】:2020-08-07 15:27:43
【问题描述】:

问题

我最近刚刚从一个分叉存储库中的 expo 中退出,并在尝试构建 iOS 应用程序时遇到了一个问题,无法解析我现有的图像和字体资产。

步骤

npm 安装

展会弹出

纱线 ios

预期结果

在安装 pod 并清除依赖项后运行应用程序。

实际结果

我尝试注释掉导入字体的行,以查看这些文件是否存在问题,但我尝试解决的图像存在相同问题。这是我的 App.js 文件:

import React, { Component } from 'react';
import AppNavigator from './navigation/AppNavigator.js';
import AppIntroSlider from 'react-native-app-intro-slider';
import { View, Text, Image, StyleSheet } from 'react-native';

import Amplify from 'aws-amplify';
import awsmobile from './aws-exports';
Amplify.configure(awsmobile);

import { composeWithDevTools } from 'redux-devtools-extension'
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from './store/reducers/rootReducer';
import { Provider } from 'react-redux';
import { AppLoading } from 'expo';
import * as Font from 'expo-font';

// Accessing the store and associated components
// If adding additional dispatching action files, ensure they are added to the rootReducer
 const store = createStore(
   rootReducer,
   composeWithDevTools(applyMiddleware(thunk))
 );

 // Fonts that need to be used in the application
const fetchFonts = () => {
  return Font.loadAsync({
    'euclid-triangle': require('./assets/fonts/EuclidTriangle-Regular.ttf'),
    'euclid-triangle-bold': require('./assets/fonts/EuclidTriangle-Bold.ttf'),
    'euclid-triangle-semibold': require('./assets/fonts/EuclidTriangle-SemiBold.ttf'),
  });
};

export default class App extends Component {
  constructor(props) {
    super(props)
  }
  render() {
    // Load the font if it has not been done already
    if (!this.state.fontLoaded) {
      return (
        <AppLoading startAsync={fetchFonts}
          onFinish={() => {this.setState({fontLoaded: true})
          }}/>
      )
    }

    // If the intro slider has been dismissed the main app can be shown
    return (
      <Provider store={store}>
        <AppNavigator/>
      </Provider>
    )
  }
}

【问题讨论】:

    标签: ios reactjs xcode react-native expo


    【解决方案1】:

    退出世博会没有帮助,至少根据以前的经验, 我的建议是从头开始创建一个新项目,删除与 expo 相关的所有内容,并保留非 expo 依赖项, 至于IOS上的字体,你必须将它们添加为资源

    在IOS上添加自定义字体请参考此链接:here

    【讨论】:

      猜你喜欢
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      • 2023-02-19
      • 1970-01-01
      • 2023-01-31
      • 2017-11-09
      • 2022-12-14
      • 2019-04-16
      相关资源
      最近更新 更多