Functions
clientRun()
clientRun<
R
>(task
,profile
):R
在客户端中执行任务,可通过 resolveClientRunProfile
获取特定执行配置(仅限同步代码)
Type Parameters
Type Parameter | Default type |
---|---|
R | void |
Parameters
Parameter | Type | Description |
---|---|---|
task | () => R | 待执行任务 |
profile | ClientRunProfile | 执行配置,未设置默认获取当前环境配置 |
Returns
R
Example
ts
// 获取窗口大小
function getWindowSize() {
const { window } = resolveClientRunProfile()
return { width: window.innerWidth, height: window.innerHeight }
}
// 新开窗口
const win = window.open(...)
// 获取新窗口大小
clientRun(getWindowSize, { window: win.window })
resolveClientRunProfile()
resolveClientRunProfile():
object
获取当前执行配置(仅限同步代码)
Returns
object
document
document:
Document
location
location:
Location
navigator
navigator:
Navigator
window
window:
Window
Interfaces
ClientRunProfile
Properties
Property | Type |
---|---|
document? | Document |
location? | Location |
navigator? | Navigator |
window? | Window |