Home > Web Front-end > H5 Tutorial > body text

Implementation of Html5 clipboard function

不言
Release: 2018-06-30 09:31:05
Original
4347 people have browsed it

This article mainly introduces the implementation code of the Html5 clipboard function. The content is quite good. I will share it with you now and give it as a reference.

Vue was recently used to develop the embedded H5 of Line (a Japanese and Korean platform similar to China's WeChat). One of the requirements is to paste the current link, then send it to the PC and open it on the computer. After all the collection, I found several situations:

1. Native js method without input box

This situation is suitable for copying non-input boxes to the clipboard

     

被复制的内容

Copy after login

2. Native js method with input box

for copying The text in input, textarea

     
Copy after login

This method can also be extended and serves the same purpose as method 1. Dynamically create an input box, set its content to the content you want to copy, and finally remove or hide it.

3.js copy content to clipboard plug-in (clipboard.js)

clipboard.js official website
clipboard.js CDN address

Quote:
NPM npm install --save clipboard
CDN

                
                
                
                
                
            
                
                
            
                
            
                
Copy after login

There are many advanced usages, you can go to the official website logic for more details Clipboard official website

4 . Clipboard plug-in provided by the Vue framework vue-clipboard2

    import Vue from 'vue'
    import VueClipboard from 'vue-clipboard2'
     
    VueClipboard.config.autoSetContainer = true // add this line
    Vue.use(VueClipboard)
Copy after login

Sample1

    

Copy after login

Sample2

      

Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to implement a simple progress bar on the mobile terminal through HTML5 touch events

Html5 mobile terminal is award-winning and seamless Scroll animation implementation

html5 touch event implements sliding up and down the touch screen page

##

The above is the detailed content of Implementation of Html5 clipboard function. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!