I tried to implement a copy function for an ID using useClipBoard
, but after writing the code, it didn't copy the ID as expected.
my code like this, i cant find why it doesnt work.
<ImIconButton
name="icon-outlined-copy"
@click="() => copyText(`${templateId}`)"
></ImIconButton>
const copyAbility = async (text: string) => {
if (!text) {
return proxy.$message({
type: 'error',
message: $t('op.appManageBackstage.basicInfo.alertToast.copyFailed'),
});
}
try {
await copy(text);
proxy.$message({
type: 'success',
message: $t('op.appManageBackstage.basicInfo.alertToast.copySuccess'),
});
} catch (e) {
proxy.$message({
type: 'error',
message: $t('op.cardTool.cardDisplay.alertToast.modificationFailed'),
});
}
};
const copyText = throttleByThreeSeconds(copyAbility);
I expect that clicking on this button will copy the ID.