android - url.pathname 或 url.searchParams 不是 android react native 中的函数
问题描述
我正在研究 android react native 项目,我得到了深度链接的 URL。我正在尝试从以下 url 中查找路径名和搜索参数:https ://test.xxx.com/test/test?test=moduleName 。
var url = URL(" https://test.xxx.com/test/test?test=moduleName "); 控制台.log(url.pathName);
该代码给出了以下异常“错误:未实现”。我还从 node 安装了 URL 包。我错过了什么?
解决方案
看看这个用于 React Native 的 URL polyfill:
import { URL, URLSearchParams } from 'react-native-url-polyfill';
const url = new URL("https://test.xxx.com/test/test?test=moduleName");
const searchParams = new URLSearchParams('q=GitHub');
另请注意 - React Native 在 JavascriptCore 引擎中运行,而 Node.js/Web 在 v8 Javascript 引擎中运行。
Node.js 提供了自己的专有功能 - 流、加密、http 等。此功能在 React Native 中不可用,在第三方包(如node-libs-react-native)之外
推荐阅读
- matlab - 正在生产的内核类型
- selenium - 'UnknownError',message: '处理命令时发生未知的服务器端错误。',orgStatusMessage: '与 webdriver.io 的连接被拒绝
- three.js - 如何消除图像解码调用的冻结
- android - 项目不再使用 android studio 3.2 构建
- c# - 基于创建的新 col 或与现有 col 相比,两个表在行总和中的差异
- android - Android 如何制作全屏视频?
- python - django url 测试用例
- sas - 如何在 SAS 中为分类变量指定虚拟变量
- ios - 重用 API 管理器类和存储数据以使其可重用的最佳方法是什么
- firebase - Firebase 队列是否写入?