Skip to main content
Version: 23.2.0

Page.setGeolocation() 方法

¥Page.setGeolocation() method

设置页面的地理位置。

¥Sets the page's geolocation.

签名

¥Signature

class Page {
abstract setGeolocation(options: GeolocationOptions): Promise<void>;
}

参数

¥Parameters

范围

类型

描述

options

GeolocationOptions

Returns:

Promise<void>

备注

¥Remarks

考虑使用 BrowserContext.overridePermissions() 授予页面读取其地理位置的权限。

¥Consider using BrowserContext.overridePermissions() to grant permissions for the page to read its geolocation.

示例

¥Example

await page.setGeolocation({latitude: 59.95, longitude: 30.31667});