首页指南参考教程

URL

GitHub

npm

标准 URL API 可在所有 Expo 支持的平台上使用。

Android
iOS
tvOS
Web

标准 URL API 可在所有 Expo 支持的平台上使用。

¥The standard URL API is available on all Expo-supported platforms.

安装

¥Installation

该 API 是 expo 包的一部分。在原生平台上,内置 URLURLSearchParams 实现取代了 react-native 中的垫片。请参阅 Web 和 Node.js 的 浏览器和服务器运行时支持

¥This API is part of the expo package. On native platforms, built-in URL and URLSearchParams implementations replace the shims in react-native. Refer to the browser and server runtime support for web and Node.js.

用法

¥Usage

const url = new URL('https://expo.dev');

const params = new URLSearchParams();

一致性

¥Conformance

Expo 的内置 URL 支持尝试完全 符合规范

¥Expo's built-in URL support attempts to be fully spec compliant.

唯一缺少的例外是原生平台当前不支持主机名中的 非 ASCII 字符

¥The only missing exception is that native platforms do not currently support non-ASCII characters in the hostname.

考虑以下示例:

¥Consider the following example:

console.log(new URL('http://🥓').toString())

输出如下:

¥This outputs the following:

  • 网络、Node.js:http://xn--pr9h/

    ¥Web, Node.js: http://xn--pr9h/

  • iOS、Android:http://🥓/

Expo 中文网 - 粤ICP备13048890号