我已升级到34.0.3博览会,相关的依赖关系如下
"dependencies": {
"@expo/samples": "3.0.3",
"@expo/vector-icons": "^10.0.3",
"add": "^2.0.6",
"expo": "^34.0.3",
"expo-asset": "^5.0.1",
"expo-font": "~6.0.1",
"moment": "^2.24.0",
"react": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
"react-native-gesture-handler": "^1.3.0",
"react-native-modal": "^11.3.1",
"react-native-modal-datetime-picker": "^7.5.0",
"react-native-snackbar-component": "^1.1.0",
"react-navigation": "^3.11.1",
"react-redux": "^7.1.0",
"redux": "^4.0.4",
"redux-persist": "^5.10.0"
},
我的App.js大概正确地预加载了字体
import * as Font from 'expo-font';
import * as Icon from '@expo/vector-icons';
.........
_loadResourcesAsync = async () => {
return Promise.all([
Font.loadAsync({
...Icon.Ionicons.font,
...Icon.MaterialCommunityIcons.font,
}),
]);
};
现在要清楚一点,此代码在世博会升级之前运行良好。 在Android和iOS设备上均会看到此问题。
答案 0 :(得分:3)
我能够通过删除yarn.lock(我正在使用yarn)并在升级后删除node_modules来解决此问题。 然后再次运行纱线。
在路上,我还升级了expo cli,node,还使用expo_codemod照顾了与代码有关的所有升级相关更改。 我还必须像“ react-native-gesture-handler”那样移出“ expo install”软件包
我认为对我来说,关键是删除锁定文件并通过expo start -c清除缓存
答案 1 :(得分:1)
我通过在终端中使用以下命令解决了该问题
rm -rf ./node_modules/expo/node_modules/expo-font /
答案 2 :(得分:0)
首先确保使用正确的路径加载脚本,如下所示:
// Load fonts
await Font.loadAsync({
...Ionicons.font,
"space-mono": require("../assets/fonts/SpaceMono-Regular.ttf"),
ionicons: require("@expo/vector-icons/build/vendor/react-native-vector-icons/Fonts/Ionicons.ttf"),
anticon: require("@expo/vector-icons/build/vendor/react-native-vector-icons/Fonts/AntDesign.ttf"),
"material-community": require("@expo/vector-icons/build/vendor/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf"),
});
按照以下步骤解决了此问题(语言:打字稿):
npm install
expo install
expo start -c
清除缓存并启动应用程序