举个例子
看了就会
vant的Dialog
Dialog.confirm({
title: '一键复制内容',
message: () => {
return (
<input
id="codeInput"
style={{ border: 'none', textAlign: 'center' }}
value={code}
readonly
></input>
);
},
cancelButtonText: '返回',
confirmButtonText: '一键复制'
})
.then(() => {
// on confirm
let text = document.querySelector('#codeInput');
text.select();
document.execCommand('copy');
Toast('复制成功');
})
.catch(() => {
// on cancel
});
![测试](https://img-blog.csdnimg.cn/152ac9e767164711aa98abf4802561a9.png#pic_center)
移动端一键复制
于 2022-05-06 16:24:06 首次发布