Click the button on the front end to copy a piece of text

Click the button to copy a piece of text

If you don't try it, you will know it
const linkUrl = (item) => { let url = item;//Copied value let copyInput = document.createElement('input');//Create input element document.body.appendChild( copyInput);//Add an input box at the bottom of the page copyInput.setAttribute('value', url);//Add an attribute, assign the url to the value attribute of the input element copyInput.select();//Select the input element document.execCommand(“ Copy”);//Execute the copy command ElMessage({ message: 'Copy success', type: 'success', }) copyInput.remove();//Delete dynamically created nodes }











Guess you like

Origin blog.csdn.net/m0_71585401/article/details/131403279