Skip to content

useDevicesList

类别
导出大小
1.29 kB
最近修改
2 days ago
相关

响应式 enumerateDevices 列出可用的输入/输出设备。

🌐 Reactive enumerateDevices listing available input/output devices.

示例

Camera (0)
Microphones (0)
Speakers (0)

用法

🌐 Usage

ts
import { 
useDevicesList
} from '@vueuse/core'
const {
devices
,
videoInputs
:
cameras
,
audioInputs
:
microphones
,
audioOutputs
:
speakers
,
} =
useDevicesList
()

请求权限

🌐 Requesting Permissions

要请求权限,请使用 ensurePermissions 方法。

🌐 To request permissions, use the ensurePermissions method.

ts
const {
  
ensurePermissions
,
permissionGranted
,
} =
useDevicesList
()
await
ensurePermissions
()
console
.
log
(permissionsGranted.value)

组件

🌐 Component

vue
<template>
  <UseDevicesList v-slot="{ 
videoInputs
,
audioInputs
,
audioOutputs
}">
Cameras: {{
videoInputs
}}
Microphones: {{
audioInputs
}}
Speakers: {{
audioOutputs
}}
</UseDevicesList> </template>