在 UIManager 中找不到 BVLinearGradient?
BVLinearGradient was not found in the UIManager?
有关于此的文档,但它仅适用于 macO。 https://github.com/react-native-community/react-native-linear-gradient.
我通过 运行ning npm install react-native link react-native-linear-gradient
链接了库。
我不明白我没有 ios 文件夹,我安装了 pod 但我的 ios 文件夹仍然是空的:
iOS
对于 React Native >= 0.60.0 运行 ios/ 文件夹中的以下命令并跳过该部分的其余部分。
吊舱安装
可可豆
将以下行添加到您的 Podfile:
pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
或:
以下仅适用于 macOs ?
手动
在 Xcode 中打开您的项目,右键单击 Libraries 并单击 Add Files to "Your Project Name" 在 node_modules/react-native-linear-gradient/ios 下查找并添加 BVLinearGradient.xcodeproj。 (屏幕截图 1)(屏幕截图 2)。
添加 libBVLinearGradient.a 到 Build Phases -> Link Binary With Libraries(屏幕截图 1)(屏幕截图 2)。
在 Libraries 中单击 BVLinearGradient.xcodeproj,然后转到 Build Settings 选项卡。双击 Header Search Paths 右侧的文本并验证它是否具有 $(SRCROOT)/../react-native/React - 如果没有,则添加它。这样 Xcode 就能够通过指向安装在 react-native node_modules 目录中的头文件找到 BVLinearGradient 源文件引用的头文件。 (屏幕截图)。
如何在 Windows 中完成,我在 node_modules/react-native-linear-gradient/?[=12= 中没有 ios 地图]
我怎样才能让它发挥作用?
感谢您的宝贵时间
检查这两行是否在您的 'package file' 中。
'React', :path => '../node_modules/react-native'
'BVLinearGradient', :path =>
'../node_modules/react-native-linear-gradient'
如果是那么——
Run "pod install" under $project path/ios before react-native run-ios.
干杯!!
如果您正在使用 expo
,请使用这个
1。将其粘贴到终端 window :
expo install expo-linear-gradient
2.add 导入语句到文件:
import {LinearGradient} from 'expo-linear-gradient';
对我有用!
只需转到ios文件夹
cd ios
pod install
就是这样
首先,安装 https://github.com/react-native-community/react-native-linear-gradient 库。
然后转到 cd ios 和 运行
cd ios
pod install
现在使用 go back using cd ..
和运行(可选)
react-native link react-native-linear-gradient
现在运行
react-native run-ios
如果使用 expo 并且在安装后抛出此错误 react-native-linear-gradient 请继续。
error ?expo框架还是没有线性渐变包的“视线”。
解决方案 ? 运行 从您的根文件夹中执行“expo install expo-linear-gradient”命令,转到您之前导入线性渐变的文件作为“从'react-native-linear-gradient导入LinearGradient”并将行更改为“从'expo-linear-gradient'导入{LinerGradient}”。
重新启动您的服务器,“expo start”。
PS:此解决方案仅适用于使用 expo
构建的 react-native 个项目
如果您使用的是 windows & react-native cli(不是 expo):
1- in android/settings.gradle, 检查是否
包括':react-native-线性渐变'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
存在..如果没有,添加
2- in android/app/build.gradle, 检查是否
implementation project(':react-native-linear-gradient')
存在于依赖项{ ... } .. 如果没有,添加它
3- 在 android/app/src/main/java/com/{YOUR_APP_NAME}/MainApplication.java 中,找到
@Override
受保护列表 getPackages() { ....}
然后替换注释// packages.add(new MyReactNativePackage());
有 =>
packages.add(new LinearGradientPackage());
有关于此的文档,但它仅适用于 macO。 https://github.com/react-native-community/react-native-linear-gradient.
我通过 运行ning npm install react-native link react-native-linear-gradient
链接了库。
我不明白我没有 ios 文件夹,我安装了 pod 但我的 ios 文件夹仍然是空的:
iOS 对于 React Native >= 0.60.0 运行 ios/ 文件夹中的以下命令并跳过该部分的其余部分。
吊舱安装 可可豆 将以下行添加到您的 Podfile:
pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient' 或:
以下仅适用于 macOs ?
手动 在 Xcode 中打开您的项目,右键单击 Libraries 并单击 Add Files to "Your Project Name" 在 node_modules/react-native-linear-gradient/ios 下查找并添加 BVLinearGradient.xcodeproj。 (屏幕截图 1)(屏幕截图 2)。 添加 libBVLinearGradient.a 到 Build Phases -> Link Binary With Libraries(屏幕截图 1)(屏幕截图 2)。 在 Libraries 中单击 BVLinearGradient.xcodeproj,然后转到 Build Settings 选项卡。双击 Header Search Paths 右侧的文本并验证它是否具有 $(SRCROOT)/../react-native/React - 如果没有,则添加它。这样 Xcode 就能够通过指向安装在 react-native node_modules 目录中的头文件找到 BVLinearGradient 源文件引用的头文件。 (屏幕截图)。
如何在 Windows 中完成,我在 node_modules/react-native-linear-gradient/?[=12= 中没有 ios 地图]
我怎样才能让它发挥作用?
感谢您的宝贵时间
检查这两行是否在您的 'package file' 中。
'React', :path => '../node_modules/react-native'
'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
如果是那么——
Run "pod install" under $project path/ios before react-native run-ios.
干杯!!
如果您正在使用 expo
,请使用这个1。将其粘贴到终端 window :
expo install expo-linear-gradient
2.add 导入语句到文件:
import {LinearGradient} from 'expo-linear-gradient';
对我有用!
只需转到ios文件夹
cd ios
pod install
就是这样
首先,安装 https://github.com/react-native-community/react-native-linear-gradient 库。
然后转到 cd ios 和 运行
cd ios
pod install
现在使用 go back using cd ..
和运行(可选)
react-native link react-native-linear-gradient
现在运行
react-native run-ios
如果使用 expo 并且在安装后抛出此错误 react-native-linear-gradient 请继续。
error ?expo框架还是没有线性渐变包的“视线”。
解决方案 ? 运行 从您的根文件夹中执行“expo install expo-linear-gradient”命令,转到您之前导入线性渐变的文件作为“从'react-native-linear-gradient导入LinearGradient”并将行更改为“从'expo-linear-gradient'导入{LinerGradient}”。
重新启动您的服务器,“expo start”。 PS:此解决方案仅适用于使用 expo
构建的 react-native 个项目如果您使用的是 windows & react-native cli(不是 expo):
1- in android/settings.gradle, 检查是否
包括':react-native-线性渐变' project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
存在..如果没有,添加
2- in android/app/build.gradle, 检查是否
implementation project(':react-native-linear-gradient')
存在于依赖项{ ... } .. 如果没有,添加它
3- 在 android/app/src/main/java/com/{YOUR_APP_NAME}/MainApplication.java 中,找到
@Override 受保护列表 getPackages() { ....}
然后替换注释// packages.add(new MyReactNativePackage());
有 => packages.add(new LinearGradientPackage());