Vue implements the method of copying content to the clipboard, vueclipboard

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.