Skip to content

useEyeDropper

类别
导出体积
283 B
上次更改
2 months ago

响应式的 EyeDropper API

示例

你的浏览器不支持此功能

用法

ts
import { 
useEyeDropper
} from '@vueuse/core'
const {
isSupported
,
open
,
sRGBHex
} =
useEyeDropper
()

组件用法

vue
<template>
  <UseEyeDropper v-slot="{ 
isSupported
,
sRGBHex
,
open
}">
<
button
:disabled
="!
isSupported
" @
click
="() =>
open
()">
sRGBHex: {{
sRGBHex
}}
</
button
>
</UseEyeDropper> </template>

类型声明

ts
export interface EyeDropperOpenOptions {
  /**
   * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
   */
  
signal
?: AbortSignal
} export interface EyeDropper { new (): EyeDropper
open
: (
options
?: EyeDropperOpenOptions) =>
Promise
<{
sRGBHex
: string
}> [
Symbol
.
toStringTag
]: "EyeDropper"
} export interface UseEyeDropperOptions { /** * 初始 sRGBHex. * * @default '' */
initialValue
?: string
} /** * 响应式 [EyeDropper API](https://developer.mozilla.org/en-US/docs/Web/API/EyeDropper_API) * * @see https://vueuse.org/useEyeDropper * * @__NO_SIDE_EFFECTS__ */ export declare function
useEyeDropper
(
options
?: UseEyeDropperOptions): {
isSupported
:
ComputedRef
<boolean>
sRGBHex
:
ShallowRef
<string, string>
open
: (
openOptions
?: EyeDropperOpenOptions) =>
Promise
<
| {
sRGBHex
: string
} | undefined > } export type
UseEyeDropperReturn
=
ReturnType
<typeof
useEyeDropper
>

源码

源码演示文档

贡献者

Anthony Fu
一纸忘忧
Jelf
Anthony Fu
IlyaL
SerKo
vaakian X
wheat

更新日志

8c521 - feat(components)!: refactor components and make them consistent (#4912)
d32f8 - refactor: add @__NO_SIDE_EFFECTS__ annotations to all pure functions (#4907)
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)