使用 DevTools Microsoft Edge地理位置Override geolocation with Microsoft Edge DevTools

许多网站利用用户位置来为用户提供更相关的体验。Many websites take advantage of user location in order to provide a more relevant experience for the users. 例如,在用户授予网站访问当前用户位置的权限后,天气网站可能会显示用户区域中的本地天气预报。For example, a weather website may show the local forecast in a user's area, after the user has granted the website permission to access the current user location.

如果您要构建的 UI 根据用户所在的位置而更改,您可能需要确保网站在世界各地的不同位置正常运行。If you are building a UI that changes depending on where the user is located, you probably want to make sure that the site behaves correctly in different places around the world. 若要在 DevTools 中Microsoft Edge地理位置,请完成以下操作。To override your geolocation in Microsoft Edge DevTools, complete the following actions.

  1. 选择 Control+Shift+P (Windows、Linux) 或 Command+Shift+P (macOS) 打开命令菜单Select Control+Shift+P (Windows, Linux) or Command+Shift+P (macOS) to open the Command Menu.

    命令菜单

  2. 键入 sensors ,选择 显示传感器,然后选择 EnterType sensors, choose Show Sensors, and select Enter. 传感器 工具 将在 DevTools 窗口底部打开。The Sensors tool opens at the bottom of your DevTools window.

  3. 从"**** 地理位置"列表中选择预设城市之一(如 ),或选择"自定义位置"以输入自定义经度和纬度坐标,或选择"位置不可用"以显示当用户的位置不可用时网站的行为方式。 Tokyo **** ****From the Geolocation list select one of the preset cities, like Tokyo, or choose Custom location to enter custom longitude and latitude coordinates, or choose Location unavailable to display how your site behaves when the user's location is not available.

    从地理位置列表中选择东京

联系 Microsoft Edge 开发工具团队Getting in touch with the Microsoft Edge DevTools team

使用以下选项讨论帖子中的新功能和更改,或与 DevTools 相关的任何其他内容。Use the following options to discuss the new features and changes in the post, or anything else related to DevTools.

  • 使用“发送反馈”图标发送反馈,或在 DevTools 中选择Alt+Shift+I \ (Windows、Linux) 或 Option+Shift+I \ (macOS)。Send your feedback using the Send Feedback icon or select Alt+Shift+I (Windows, Linux) or Option+Shift+I (macOS) in DevTools.
  • 发推 @EdgeDevToolsTweet at @EdgeDevTools.
  • 我们想要的 Web 提交建议。Submit a suggestion to The Web We Want.
  • 若要提交有关本文的错误,请使用以下“反馈” 部分。To file bugs about this article, use the following Feedback section.

Microsoft Edge DevTools 中的“发送反馈”图标

备注

此页面的某些部分是根据 Google 创建和共享的作品所做的修改,并根据 Creative Commons Attribution 4.0 International License 中描述的条款使用。Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons Attribution 4.0 International License.
原始页面位于此处,由 Kayce Basques\(Chrome DevTools & Lighthouse 的技术作家\)撰写。The original page is found here and is authored by Kayce Basques (Technical Writer, Chrome DevTools & Lighthouse).

Creative Commons License
本作品根据 Creative Commons Attribution 4.0 International License 获得许可。This work is licensed under a Creative Commons Attribution 4.0 International License.