项目中会并存两个独立包:例如react-native-svg(原生跨平台库)与@react-native-oh-tpl/react-native-svg(HarmonyOS 适配补丁库)。 其中,@react-native-oh-tpl/react-native-svg仅运行于 HarmonyOS 平台,本质是在原库基础上叠加 HarmonyOS 适配补丁:其他平台仍沿用原库逻辑,不受影响 二、补丁库的配置方式 只需在补丁库的package.json中添加harmony字段配置别名,即可完成适配映射: { "name": "@react-native-oh-tpl/react-native-svg ", "harmony": { "alias": "react-native-svg" }, // 其他配置项 } React Native for HarmonyOS(RNOH) 会根据平台自动重定向依赖:当开发者在代码中使用import Svg from "react-native-svg"时,HarmonyOS 平台会自动加载@react-native-oh-tpl/react-native-svg
RN 的 SVG 支持是基于 react-native-svg 这个仓库,它更多的功能是作为底层库支持上层图表的使用。 Github: https://github.com/software-mansion/react-native-svg 3.megadraft 基于 Facebook Draft.js 的富文本编辑器
async-storage react-native-storage 导航 功能齐全的导航库的依赖项 react-native-screens react-native-router-flux svg react-native-svg
还有一些非官方但很好用的组件,例如 react-native-svg、react-native-camera 等等。 如果要使用「径向渐变」,可以使用 react-native-svg[21] 的 RadialGradient 组件。 1.SVG RN 的 SVG 支持是基于 react-native-svg[22] 这个仓库,就个人的使用体验来说,基本和 Web 的 SVG 功能没啥两样。
下面我以 react-native-svg 这个第三方库为例进行说明: 1.检查 android/settings.gradle,删除旧的 include 配置,加入下面新的代码: rootProject.name = '你的项目' - include ':react-native-svg' - project(':react-native-svg').projectDir = new File(rootProject.projectDir /node_modules/react-native-svg/android') + apply from: file(".. app' 2.检查 android/app/build.gradle,删除旧的配置,文件的最后一行加入一行配置: dependencies { - implementation project(':react-native-svg
identifier 标识符即可, 你的手机可能已经安装了一个这样的包,(连接上手机) 'RNSVGLinearGradient' was not found in the UIManager 装一下 react-native-svg
branch: 'specBranch', localDir: 'specDir' }, // 发布插件相关配置 dependencies: { "react-native-svg
React-native-web 安装 npm install react react-dom react-native-web --save 如果使用了 ART,需要安装 react-art(比如,使用了 react-native-svg