gpt4 book ai didi

javascript - React Native : . matchAll 不是函数

转载 作者:行者123 更新时间:2023-12-04 13:31:14 25 4
gpt4 key购买 nike

运行我的 React Native 应用程序时出现一个奇怪的错误:
一些示例代码:

const { url } = <incoming object>;
const reURL = <my regex>;

console.debug('url:', url);
console.debug('typeof url:', typeof url);

matches = [...url.matchAll(reURL)];
日志输出:
url: <as expected>
typeof url: string
错误信息:
TypeError: url.matchAll is not a function. (In 'url.matchAll(reURL)', 'url.matchAll' is undefined)
在 iOS 上一切正常,该错误仅在 Android 上发生。
相当最新的环境,全部更新 npm几天前的包裹。
有谁知道从哪里开始寻找解决方案?

最佳答案

您可以使用 string.prototype.matchall填充。
https://www.npmjs.com/package/string.prototype.matchall

import matchAll from 'string.prototype.matchAll'

matchAll.shim()

关于javascript - React Native : <string>. matchAll 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64935512/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com