描述
window.URL对象在Hermes中可用,但其他实现未实现。所有访问器都有错误。
react-native/packages/react-native/Libraries/Blob/URL.js
第140行到第230行
| | constructor(url: string,base: string|URL){ |
| | letbaseUrl=null; |
| | if(!base||validateBaseUrl(url)){ |
| | this._url=url; |
| | if(!this._url.endsWith('/')){ |
| | this._url+='/'; |
| | } |
| | }else{ |
| | if(typeofbase==='string'){ |
| | baseUrl=base; |
| | if(!validateBaseUrl(baseUrl)){ |
| | thrownewTypeError(Invalid base URL: ${baseUrl}
); |
| | } |
| | }else{ |
| | baseUrl=base.toString(); |
| | } |
| | if(baseUrl.endsWith('/')){ |
| | baseUrl=baseUrl.slice(0,baseUrl.length-1); |
| | } |
| | if(!url.startsWith('/')){ |
| | url=/${url}
; |
| | } |
| | if(baseUrl.endsWith(url)){ |
| | url=''; |
| | } |
| | this._url=${baseUrl}${url}
; |
| | } |
| | } |
| | gethash(): string{ |
| | thrownewError('URL.hash is not implemented'); |
| | } |
| | gethost(): string{ |
| | thrownewError('URL.host is not implemented'); |
| | } |
| | gethostname(): string{ |
| | thrownewError('URL.hostname is not implemented'); |
| | } |
| | gethref(): string{ |
| | returnthis.toString(); |
| | } |
| | getorigin(): string{ |
| | thrownewError('URL.origin is not implemented'); |
| | } |
| | getpassword(): string{ |
| | thrownewError('URL.password is not implemented'); |
| | } |
| | getpathname(): string{ |
| // ...省略部分代码...//
const urlObj = new window.URL( validUrlString );
urlObj.hostname
// Error: URL.hostname is not implemented
|
const urlObj = new window.URL( validUrlString );
urlObj.hostname
// Error: URL.hostname is not implemented
如何重现问题?
const urlObj = new window.URL( validUrlString );
urlObj.hostname
// Error: URL.hostname is not implemented
React Native版本
0.73.6
受影响的平台
运行时-Android
Reproducible on all systems. The code has a baked-in Error and no implementation.
输出
This error is located at:
in SecureContext (created by Connect(SecureContext))
in Connect(SecureContext) (created by App)
in RCTView (created by View)
in View (created by App)
in App (created by RenderApp)
in Provider (created by RenderApp)
in RenderApp
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in app(RootComponent), js engine: hermes
堆栈跟踪或日志x1a3b1x无法在浏览器中重现,只能在hermes/Android上看到,因此这无关紧要。x1a4b1x截图和视频无响应
6条答案
按热度按时间gj3fmq9x1#
epfja78i2#
⚠️ React Native的新版本可用!
i️ 您当前使用的是受支持的次要版本,但似乎有一个更新的补丁可用 - 0.73.8。请升级。
这是最新版本的代码,显示功能尚未实现。
react-native/packages/react-native/Libraries/Blob/URL.js
第169行到第219行 4cee0a4
| | gethash(): string{ |
| | thrownewError('URL.hash is not implemented'); |
| | } |
| | |
| | gethost(): string{ |
| | thrownewError('URL.host is not implemented'); |
| | } |
| | |
| | gethostname(): string{ |
| | thrownewError('URL.hostname is not implemented'); |
| | } |
| | |
| | gethref(): string{ |
| | returnthis.toString(); |
| | } |
| | |
| | getorigin(): string{ |
| | thrownewError('URL.origin is not implemented'); |
| | } |
| | |
| | getpassword(): string{ |
| | thrownewError('URL.password is not implemented'); |
| | } |
| | |
| | getpathname(): string{ |
| | thrownewError('URL.pathname not implemented'); |
| | } |
| | |
| | getport(): string{ |
| | thrownewError('URL.port is not implemented'); |
| | } |
| | |
| | getprotocol(): string{ |
| | thrownewError('URL.protocol is not implemented'); |
| | } |
| | |
| | getsearch(): string{ |
| | thrownewError('URL.search is not implemented'); |
| | } |
| | |
| | getsearchParams(): URLSearchParams{ |
| | if(this._searchParamsInstance==null){ |
| | this._searchParamsInstance=newURLSearchParams(); |
| | } |
| | returnthis._searchParamsInstance; |
| | } |
| | |
| | toJSON(): string{ |
| // 请升级。
dfty9e193#
你好,我是sossost,一个新贡献者。我可以尝试解决这个问题吗?
tct7dpnv4#
请做👍
m3eecexj5#
你好,我是Shivanand,新的贡献者。我可以尝试解决这个问题吗?请提供有关此问题的简要信息。
9nvpjoqh6#
嘿,我几天前学了JS和版本控制,我愿意贡献...我不知道如何开始...有人能帮我吗?