Skip to content

createProjection

从一个域到另一个域的反应式数字投影。

¥Reactive numeric projection from one domain to another.

用法

¥Usage

ts
import { createProjection } from '@vueuse/math'

const useProjector = createProjection([0, 10], [0, 100])
const input = ref(0)
const projected = useProjector(input) // projected.value === 0

input.value = 5 // projected.value === 50
input.value = 10 // projected.value === 100

类型声明

typescript
export declare function createProjection(
  fromDomain: MaybeRefOrGetter<readonly [number, number]>,
  toDomain: MaybeRefOrGetter<readonly [number, number]>,
  projector?: ProjectorFunction<number, number>,
): UseProjection<number, number>

源代码

源代码文档

变更日志

No recent changes

VueUse 中文网 - 粤ICP备13048890号