reactjs - 如何在 React Native Webview 组件中使用 Reactjs 库
问题描述
所以正如标题所说,我正在尝试在 React Native Webview 中运行 Reactjs 库,但我没有任何运气。
我的网络视图
<WebView
source={{html: html}}
style={{
flex: 1,
marginLeft: 0,
marginRight: 0,
marginTop: 21,
marginBottom: 21,
width: '100%',
height: 263
}}
scrollEnabled={false}
/>
我的html字符串
const html = `
<!DOCTYPE html>
<html lang="en">
<title>Test React</title>
<script src= "https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script src= "https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<body>
<div id="root"/>
<script type="text/babel">
import RadarChart from 'react-svg-radar-chart';
import 'react-svg-radar-chart/build/css/index.css';
ReactDOM.render(
<div>
<p>hello</p>
<RadarChart
captions={${captions}}
data={${data}}
size={450}
/>
</div>,
document.getElementById('root'));
</script>
</body>
</html>
`;
我在我的 react native 项目中安装了该库,并尝试将组件连接到像${RadarChart}这样的 html 字符串中,但这不起作用,所以我假设没有办法使用 Webview 使用本地库。有没有人有更好的主意?
解决方案
推荐阅读
- json - Angular AoT 构建导入本地 json 文件
- java - 使用 REST Api 删除 OTDS 用户 - 无法删除同步对象
- javascript - 需要一个在每个 ID 上运行的脚本,而不仅仅是最后一个调用
- entity-framework-migrations - 无法在 dotnet core ef 中添加迁移和更新数据库
- ios - Xcode 中的编译器错误“需要 -Onone swift 优化级别”需要什么操作?
- python - 替换excel表格中的数据
- gcc - gcc 和 ld 拒绝静态链接库
- php - HTACCESS 删除 .php 扩展名,除了某些 url
- javascript - API 调用上的 Node.js 循环
- python - 如何使用python将嵌套子节点添加到xml文档中的父节点?