Home > Web Front-end > JS Tutorial > Vue quickly copies content to the pasteboard (code attached)

Vue quickly copies content to the pasteboard (code attached)

php中世界最好的语言
Release: 2018-05-10 14:27:19
Original
4521 people have browsed it

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
Copy after login

2 . import the introduction file

import Clipboard from 'clipboard';
Copy after login

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>
Copy after login

4. Find the content in an element by class name in JavaScript.

let clipboard = new Clipboard('.copyBtn');
Copy after login

That’s it. If you need this address, just

reference the clipboard variable in the method. If not, Don't worry about this variable, it doesn't need any processing. After clicking the button with the class name copyBtn, just Ctrl v.

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template