clipboard 在 vue 中的使用

簡介

頁面中用 clipboard 可以進行復制粘貼,clipboard能將內容直接寫入剪切板

安裝

npm install --save clipboard

使用方法一

<template><span>{{ code }}</span><iclass="el-icon-document"title="點擊復制"@click="copyActiveCode($event,code )"/>
</template>
// methods
copyActiveCode(e, text) {const clipboard = new Clipboard(e.target, { text: () => text })clipboard.on('success', e => {this.$message({ type: 'success', message: '復制成功' })// 釋放內存clipboard.off('error')clipboard.off('success')clipboard.destroy()})clipboard.on('error', e => {// 不支持復制this.$message({ type: 'waning', message: '該瀏覽器不支持自動復制' })// 釋放內存clipboard.off('error')clipboard.off('success')clipboard.destroy()})clipboard.onClick(e)}

使用方法二

<template><span>{{ code }}</span><iid="tag-copy" <-- 作為選擇器的標識使用用class也行 -->:data-clipboard-text="code"  <-- 這里放要復制的內容 -->class="el-icon-document"title="點擊復制"@click="copyActiveCode($event,code)"/>
</template>
// methods
copyActiveCode() {const clipboard = new Clipboard("#tag-copy")clipboard.on('success', e => {this.$message({ type: 'success', message: '復制成功' })// 釋放內存clipboard.destroy()})clipboard.on('error', e => {// 不支持復制this.$message({ type: 'waning', message: '該瀏覽器不支持自動復制' })// 釋放內存clipboard.destroy()})}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/389466.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/389466.shtml
英文地址,請注明出處:http://en.pswp.cn/news/389466.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

數據驅動開發_開發數據驅動的股票市場投資方法

數據驅動開發Data driven means that your decision are driven by data and not by emotions. This approach can be very useful in stock market investment. Here is a summary of a data driven approach which I have been taking recently數據驅動意味著您的決定是由數據…

前端之sublime text配置

接下來我們來了解如何調整sublime text的配置&#xff0c;可能很多同學下載sublime text的時候就是把它當成記事本來使用&#xff0c;也就是沒有做任何自定義的配置&#xff0c;做一些自定義的配置可以讓sublime text更適合我們的開發習慣。 那么在利用剛才的命令面板我們怎么打…

python 時間序列預測_使用Python進行動手時間序列預測

python 時間序列預測Time series analysis is the endeavor of extracting meaningful summary and statistical information from data points that are in chronological order. They are widely used in applied science and engineering which involves temporal measureme…

keras框架:目標檢測Faster-RCNN思想及代碼

Faster-RCNN&#xff08;RPN CNN ROI&#xff09;概念 Faster RCNN可以分為4個主要內容&#xff1a; Conv layers&#xff1a;作為一種CNN網絡目標檢測方法&#xff0c;Faster RCNN首先使用一組基礎的convrelupooling層提取 image的feature maps。該feature maps被共享用于…

算法偏見是什么_算法可能會使任何人(包括您)有偏見

算法偏見是什么在上一篇文章中&#xff0c;我們展示了當數據將情緒從動作中剝離時會發生什么 (In the last article, we showed what happens when data strip emotions out of an action) In Part 1 of this series, we argued that data can turn anyone into a psychopath, …

大數據筆記-0907

2019獨角獸企業重金招聘Python工程師標準>>> 復習: 1.clear清屏 2.vi vi xxx.log i-->edit esc-->command shift:-->end 輸入 wq 3.cat xxx.log 查看 --------------------------- 1.pwd 查看當前光標所在的path 2.家目錄 /boot swap / 根目錄 起始位置 家…

Tensorflow框架:目標檢測Yolo思想

Yolo-You Only Look Once YOLO算法采用一個單獨的CNN模型實現end-to-end的目標檢測&#xff1a; Resize成448448&#xff0c;圖片分割得到77網格(cell)CNN提取特征和預測&#xff1a;卷積部分負責提取特征。全鏈接部分負責預測&#xff1a;過濾bbox&#xff08;通過nms&#…

線性回歸非線性回歸_了解線性回歸

線性回歸非線性回歸Let’s say you’re looking to buy a new PC from an online store (and you’re most interested in how much RAM it has) and you see on their first page some PCs with 4GB at $100, then some with 16 GB at $1000. Your budget is $500. So, you es…

樸素貝葉斯和貝葉斯估計_貝葉斯估計收入增長的方法

樸素貝葉斯和貝葉斯估計Note from Towards Data Science’s editors: While we allow independent authors to publish articles in accordance with our rules and guidelines, we do not endorse each author’s contribution. You should not rely on an author’s works wi…

numpy統計分布顯示

import numpy as np from sklearn.datasets import load_iris dataload_iris()petal_lengthnumpy.array(list(len[2]for len in data[data]))#取出花瓣長度數據 print(np.max(petal_length))#花瓣長度最大值 print(np.mean(petal_length))#花瓣長度平均值 print(np.std(petal_l…

python數據結構:進制轉化探索

*********************************第一部分******************************************************************************************************************************************************************************************# 輸入excel的行號&#xff0c;…

Keras框架:人臉檢測-mtcnn思想及代碼

人臉檢測-mtcnn 概念&#xff1a; MTCNN&#xff0c;英文全稱是Multi-task convolutional neural network&#xff0c;中文全稱是多任務卷積神經網絡&#xff0c; 該神經網絡將人臉區域檢測與人臉關鍵點檢測放在了一起。 從工程實踐上&#xff0c;MTCNN是一種檢測速度和準確率…

python中格式化字符串_Python中所有字符串格式化的指南

python中格式化字符串Strings are one of the most essential and used datatypes in programming. It allows the computer to interact and communicate with the world, such as printing instructions or reading input from the user. The ability to manipulate and form…

Javassist實現JDK動態代理

提到JDK動態代理&#xff0c;相信很多人并不陌生。然而&#xff0c;對于動態代理的實現原理&#xff0c;以及如何編碼實現動態代理功能&#xff0c;可能知道的人就比較少了。接下一來&#xff0c;我們就一起來看看JDK動態代理的基本原理&#xff0c;以及如何通過Javassist進行模…

數據圖表可視化_數據可視化如何選擇正確的圖表第1部分

數據圖表可視化According to the World Economic Forum, the world produces 2.5 quintillion bytes of data every day. With so much data, it’s become increasingly difficult to manage and make sense of it all. It would be impossible for any person to wade throug…

Keras框架:實例分割Mask R-CNN算法實現及實現

實例分割 實例分割&#xff08;instance segmentation&#xff09;的難點在于&#xff1a; 需要同時檢測出目標的位置并且對目標進行分割&#xff0c;所以這就需要融合目標檢測&#xff08;框出目標的位置&#xff09;以及語義分割&#xff08;對像素進行分類&#xff0c;分割…

機器學習 缺陷檢測_球檢測-體育中的機器學習。

機器學習 缺陷檢測&#x1f6a9; 目標 (&#x1f6a9;Objective) We want to evaluate the quickest way to detect the ball in a sport event in order to develop an Sports AI without spending a million dollars on tech or developers. Quickly we find out that detec…

莫煩Pytorch神經網絡第二章代碼修改

import torch import numpy as np""" Numpy Torch對比課程 """ # #tensor與numpy格式數據相互轉換 # np_data np.arange(6).reshape((2,3)) # print(np_data) # # torch_data torch.from_numpy(np_data) # print(\n,torch_data) # # tensor2ar…

自定義字符類

當 VC不使用MFC&#xff0c;無法使用屬于MFC的CString&#xff0c;為此自定義一個&#xff0c;先暫時使用&#xff0c;后續完善。 頭文件&#xff1a; #pragma once#define MAX_LOADSTRING 100 // 最大字符數class CString {public:char *c_str, cSAr[MAX_LOADSTRING];WCHAR *w…

使用python和javascript進行數據可視化

Any data science or data analytics project can be generally described with the following steps:通常可以通過以下步驟來描述任何數據科學或數據分析項目&#xff1a; Acquiring a business understanding & defining the goal of a project 獲得業務理解并定義項目目…