我已安装 react-native-vector-icons 并将其链接到我的项目。我正在使用 android 模拟器在我的 mac 上进行测试。
这是我的进口:
import Icon from 'react-native-vector-icons/MaterialIcons';
这就是我使用它的方式:
<Icon name='more vert' size={20} color='#24572c'/>
当我尝试构建此错误时。不知道为什么或如何处理它。
error: bundling failed: Error: While resolving module `react-native-vector-icons/MaterialIcons`, the Haste package `react-native-vector-icons` was found. However the module `MaterialIcons` could not be found within the package. Indeed, none of these files exist:
* `/Users/Alia/Desktop/GroceriesApp/node_modules/react-native/local-cli/core/__fixtures__/files/MaterialIcons(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
* `/Users/Alia/Desktop/GroceriesApp/node_modules/react-native/local-cli/core/__fixtures__/files/MaterialIcons/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
at MissingFileInHastePackageError (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:400:5)
at resolveHasteName (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:385:9)
at ModuleResolver._resolveDependency (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:315:37)
at ModuleResolver.resolveDependency (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:311:877)
at ResolutionRequest.resolveDependency (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:96:16)
at DependencyGraph.resolveDependency (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/node-haste/DependencyGraph.js:269:4352)
at /Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:201:36
at next (native)
at step (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:306)
at /Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:536