js常用复制功能
方式一:
//方式一:支持http
let str= "aaaaa" const copyInput = document.createElement('input'); copyInput.value = str; document.body.appendChild(copyInput); copyInput.select(); document.execCommand('Copy');
//方式二:不支持http
let textValue= "aaaaa"
navigator?.clipboard
?.writeText(textValue)
.then(() => {
message.success('复制成功');
})
.catch(() => {
message.error('复制失败');
});

浙公网安备 33010602011771号