我想向我的应用程序添加一些图标,但我不断收到相同的错误。
我尝试向我的应用程序添加图标,但总是遇到相同的错误。
首先我尝试使用
@expo/vector-icons
(npmjs.com),安装成功,但出现此错误:
错误类型错误:无法读取未定义的属性“isLoaded”
这是代码:
import React from 'react';
import { View, Text } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
const App = () => {
return (
<View>
<Text>This is a test</Text>
<Ionicons name="md-checkmark-circle" size={32} color="green" />
</View>
)
}
export default App;
我也尝试以不同的方式导入:
import React from 'react';
import { View, Text } from 'react-native';
import FontAwesome from '@expo/vector-icons/FontAwesome';
const App = () => {
return (
<View>
<Text>This is a test</Text>
<FontAwesome name="facebook" size={32} color="green" />
</View>
)
}
export default App;
接下来我想尝试使用库
react-native-vector-icons
(npmjs.com),也安装成功,但得到了同样的错误:
错误类型错误:无法读取未定义的属性“isLoaded”
这是代码:(使用this教程)
import React from 'react';
import { View, Text } from 'react-native';
import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
const App = () => {
return (
<View>
<Text>This is a test</Text>
<FontAwesomeIcon name="star-o" size={50} />
</View>
)
}
export default App;
有人可以帮忙吗?
好吧。问题解决了。
使用了错误的库版本。 通过运行以下命令可以轻松更改:
npx expo 安装--修复