以下是代码 我是在vue中使用的,searchInput为dom元素,document.execCommand(‘Copy’)为浏览器复制命令,select()方法直接调用。 copyText() { let refs = this.$refs let searchInput = refs.searchInput searchInput.select() document.execCommand('Copy') }