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
被复制的内容
2. Native js method with input box
for copying The text in input, textarea
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
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)
Sample1
Sample2
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!