Home > Article > Web Front-end > Vue quickly copies content to the pasteboard (code attached)
This time I will bring you Vue to quickly copy content to the pasteboard (with code). What are the precautions for Vue to quickly copy content to the pasteboard? The following is a practical case, let's take a look.
1 . npm installed into the project directory file
npm install clipboard --save
2 . import the introduction file
import Clipboard from 'clipboard';
3 . Write the content to be copied in the data-clipboard-text of the custom attribute in the required html element
<button class="copyBtn" :data-clipboard-text = "https://www.baidu.com/" type="text">复制地址</button>
4. Find the content in an element by class name in JavaScript.
let clipboard = new Clipboard('.copyBtn');That’s it. If you need this address, just I believe you have mastered the method after reading the case in this article, more Please pay attention to other related articles on the php Chinese website! Recommended reading:
aggregate cascade query implementation steps
JS analysis of the method of generating a QR code image from a link
The above is the detailed content of Vue quickly copies content to the pasteboard (code attached). For more information, please follow other related articles on the PHP Chinese website!