Skip to content

useZoomLevel

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

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

用法

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

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

立即设置初始缩放级别

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

const level = useZoomLevel(2)

传递一个 ref,当源 ref 更改时,级别将更新

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

const level = ref(1)

useZoomLevel(level) // 级别将与 ref 匹配

level.value = 2 // 级别将更改

类型声明

typescript
export declare function useZoomLevel(level: MaybeRef<number>): Ref<number>
export declare function useZoomLevel(
  webFrame: WebFrame,
  level: MaybeRef<number>,
): Ref<number>
export declare function useZoomLevel(webFrame: WebFrame): Ref<number>
export declare function useZoomLevel(): Ref<number>

Source

SourceDocs

贡献者

Anthony Fu
丶远方
Anthony Fu
Curt Grimes
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.