Skip to content

useZoomFactor

Category
Export Size
317 B
Package
@vueuse/electron
Last Changed
15 minutes ago

响应式的 WebFrame 缩放因子。 Available in the @vueuse/electron add-on.

用法

ts
import { useZoomFactor } from '@vueuse/electron'

// 如果没有显式提供 webFrame,请启用 nodeIntegration
// 参见:https://www.electronjs.org/docs/api/webview-tag#nodeintegration
// 返回 Ref 结果
const factor = useZoomFactor()
console.log(factor.value) // 打印当前缩放因子
factor.value = 2 // 修改当前缩放因子

立即设置初始缩放因子

js
import { useZoomFactor } from '@vueuse/electron'

const factor = useZoomFactor(2)

传递一个 ref,当源 ref 更改时,缩放因子将更新

js
import { useZoomFactor } from '@vueuse/electron'

const factor = ref(1)

useZoomFactor(factor) // 缩放因子将与 ref 匹配

factor.value = 2 // 缩放因子将更改

类型声明

typescript
export declare function useZoomFactor(factor: MaybeRef<number>): Ref<number>
export declare function useZoomFactor(
  webFrame: WebFrame,
  factor: MaybeRef<number>,
): Ref<number>
export declare function useZoomFactor(webFrame: WebFrame): Ref<number>
export declare function useZoomFactor(): Ref<number>

Source

SourceDocs

贡献者

Anthony Fu
丶远方
Anthony Fu
ArcherGu

变更日志

v10.7.0 on 12/5/2023
fccf2 - feat: upgrade deps (#3614)
v10.0.0-beta.5 on 4/13/2023
cb644 - refactor!: remove isFunction and isString utils

Released under the MIT License.