Vue implements the method of copying content to the clipboard, vueclipboard
1. Install npm in the project directory file
Npm install clipboard -- save
2. import the file
Import Clipboard from 'clipboard ';
3. Write the content to be copied to data-clipboard-text in the custom attribute of the html element.
<Button class = "copyBtn": data-clipboard-text = "https://www.baidu.com/" type = "text"> copy address </button>
4. Find the content in the element through the class name in JavaScript.
Let clipboard = new Clipboard ('. copyBtn ');
This is what it looks like. If you need this address, you can directly reference the clipboard variable in the method. If you don't need this variable, you don't need to worry about it. It doesn't need to be processed, click the copyBtn button and press Ctrl + v.
The above method of copying content to the clipboard in vue is to share all the content with you. I hope to give you a reference and support for the customer's house.