我无法使用react-native-vector-icons中的Icon组件。我以前可以毫无问题地使用它,但是现在,当我将Icon组件导入到我用Expo创建的App.js文件中时,出现了错误。
我已经卸载并重新安装了Expo,已经卸载并重新安装了react-native-elements,并创建了一个新的Expo项目。
这是我来自Expo的App.js文件。与默认App.js文件相比,唯一更改的是导入了Icon和Button组件。 Button组件正确呈现。
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Icon, Button } from 'react-native-elements';
export default function App() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<Button title='hello' />
<Icon
name='g-translate'
color='#00aced'
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
这是我的package.json:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "^33.0.0",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
"react-native-elements": "^1.1.0",
"react-native-vector-icons": "^6.6.0",
"react-native-web": "^0.11.4"
},
"devDependencies": {
"babel-preset-expo": "^5.1.1"
},
"private": true
}
我收到错误[未处理的承诺被拒绝:错误:file:/// Users / {myusername} / Library / Developer / CoreSimulator / Devices / CE65DD4F-AFFE-46F7-A173-6B25AF30CBCE / data / Containers / Data的目录/Application/DB21F77C-3BE4-470E-AA62-52E6C8376F0C/Library/Caches/ExponentExperienceData/%2540psoren%252FOctave/ExponentAsset-b06871f281fee6b241d60582ae9369b9.ttf不存在。] -createErrorFromErrorData中的node_modules / react-native / Libraries / BatchedBridge / NativeModules.js:155:41 -
中的node_modules / react-native / Libraries / BatchedBridge / NativeModules.js:104:55