useCopySelector
Introduction
拷贝选择器的文本内容
Basic Usage
ts
import { useCopySelector } from '@flypeng/tool/browser';
Online Demo
useCopy
@flypeng-tool - useCopySelector
复制结果:失败
<template>
<div class="copyDom">@flypeng-tool - useCopySelector</div>
<button @click="copy">点击</button>
<div>复制结果:{{ copyResult ? '成功' : '失败' }}</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { useCopySelector } from '@flypeng/tool/browser';
const copyResult = ref(false);
const copy = () => {
copyResult.value = useCopySelector('.copyDom');
};
</script>
<style scoped>
button {
width: 80px;
border-radius: 4px;
color: #ffffff;
background-color: var(--vp-c-brand);
margin: 10px 0;
}
</style>
Type Declaration
ts
/**
* 拷贝选择器的文本内容
* @param selector DOM selector
* @returns
*/
declare function useCopySelector(selector: string): boolean;