Skip to content

torch

NPM version

Platform Support

Platform Support

介绍:

手电筒插件

Reference

Method

  • toggleTorch

    打开/关闭手电筒

ts
import { 
torchPlugin
} from "@plaoc/plugins";
await
torchPlugin
.
toggleTorch
();
  • getTorchState

    手电筒状态

ts
import { 
torchPlugin
} from "@plaoc/plugins";
await
torchPlugin
.
getTorchState
();

Usage Plugins

vue
<script setup lang="ts">
import { 
torchPlugin
} from "@plaoc/plugins";
async function
toggleTorch
() {
await
torchPlugin
.
toggleTorch
();
} async function
getTorchState
() {
await
torchPlugin
.
getTorchState
();
} </script>

Usage WebComponent

vue
<script setup lang="ts">
import { 
ref
,
onMounted
} from "vue";
import {
HTMLDwebTorchElement
} from "@plaoc/plugins";
const
$torchPlugin
=
ref
<
HTMLDwebTorchElement
>();
let
torch
:
HTMLDwebTorchElement
;
onMounted
(() => {
torch
=
$torchPlugin
.
value
!;
}); async function
toggleTorch
() {
await
torch
.
toggleTorch
();
} async function
getTorchState
() {
await
torch
.
getTorchState
();
} </script> <template> <
dweb-torch
ref
="
$torchPlugin
"></
dweb-torch
>
</template>

基于 MIT 许可发布