网站地图

了解如何使用站点地图通过 Expo Router 调试你的应用。


在原生上,你可以使用 uri-scheme CLI 测试在设备上打开原生链接。

¥On native, you can use the uri-scheme CLI to test opening native links on a device.

例如,如果你想在 iOS 上启动 Expo Go 应用前往 /form-sheet 路由,请运行:

¥For example, if you want to launch the Expo Go app on iOS to the /form-sheet route, run:

Terminal
npx uri-scheme open exp://192.168.87.39:19000/--/form-sheet --ios

192.168.87.39:19000 替换为运行 npx expo start 时显示的 IP 地址。

¥Replace 192.168.87.39:19000 with the IP address shown when running npx expo start.

你还可以直接在 Safari 或 Chrome 等浏览器中搜索链接,以在物理设备上测试深度链接。了解有关 测试深层链接 的更多信息。

¥You can also search for links directly in a browser like Safari or Chrome to test deep linking on physical devices. Learn more about testing deep links.

网站地图

¥Sitemap

Expo Router 目前会自动注入 /_sitemap,提供应用中所有路由的列表。这对于调试很有用。

¥Expo Router currently injects a /_sitemap automatically that provides a list of all routes in the app. This is useful for debugging.

在 SDK 52 及以上版本中,可以通过在应用配置中将 sitemap: false 添加到 expo-router 配置插件来删除站点地图:

¥In SDK 52 and above, the sitemap can be removed by adding sitemap: false to the expo-router config plugin in the app config:

app.json
{
  "plugins": [
    [
      "expo-router",
      {
        "sitemap": false
      }
    ]
  ]
}

在 SDK 51 及以下版本中,可以通过在应用目录中创建一个空的 _sitemap 文件来删除站点地图:

¥In SDK 51 and below, the sitemap can be removed by creating an empty _sitemap file insdide the app directory:

app/_sitemap.tsx
export default function Sitemap() {
  return null;
}