Skip to content

clientRun

Namespaces

Functions

clientRun()

clientRun<R>(task, profile): R

在客户端中执行任务,可通过 resolveProfile 获取特定执行配置(仅限同步代码)

Type parameters

ParameterValue
Rvoid

Parameters

ParameterTypeDescription
task() => R待执行任务
profileClientRunProfile执行配置,未设置默认获取当前环境配置

Returns

R

Example

ts
// 获取窗口大小
function getWindowSize() {
  const { window } = clientRun.resolveProfile()
  return { width: window.innerWidth, height: window.innerHeight }
}

// 新开窗口
const win = window.open(...)

// 获取新窗口大小
clientRun(getWindowSize, { window: win.window })

Interfaces

ClientRunProfile

Properties

PropertyTypeDescription
document?Document-
location?Location-
navigator?Navigator-
window?Window-