最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue使用Clipboard.JS在h5頁(yè)面中復(fù)制內(nèi)容實(shí)例詳解

 更新時(shí)間:2019年09月03日 16:02:43   作者:手指樂(lè)  
在本篇文章里小編給大家整理了關(guān)于Vue使用Clipboard.JS在h5頁(yè)面中復(fù)制內(nèi)容以及相關(guān)知識(shí)點(diǎn)內(nèi)容,需要的朋友們可以學(xué)習(xí)下。

安裝clipboard.js

github路徑:https://github.com/zenorocha/clipboard.js

安裝:

npm install clipboard --save

引入clipboard.js

import ClipboardJS from "clipboard";

<script src="https://clipboardjs.com/dist/clipboard.min.js"></script>

使用:

剪切

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no">
  <title>dfsf</title>

  <script src="https://clipboardjs.com/dist/clipboard.min.js"></script>
  <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
  <script>
    $(function() {
      new ClipboardJS('.btn');
    })
  </script>
</head>

<body>
  <div>
    <!-- Target -->
    <textarea id="bar">Mussum ipsum cacilds...</textarea>

    <!-- Trigger -->
    <button class="btn" data-clipboard-action="cut" data-clipboard-target="#bar">
  Cut to clipboard
</button>

  </div>

</body>

</html>

復(fù)制

<button class="btn" data-clipboard-action="copy" data-clipboard-target="#bar">

3.在vue中使用并自定義復(fù)制內(nèi)容,定義復(fù)制回調(diào):

<div class="dlbtn cpkw" @click="copykeyword">復(fù)制關(guān)鍵詞</div>

·····
copykeyword() {
   var clipboard = new ClipboardJS(".cpkw", {
    text: function(trigger) {
     //alert("ok");
     return "testvalue";
    }
   });
   clipboard.on("success", e => {
    //復(fù)制成功
    // 釋放內(nèi)存
    clipboard.destroy();
   });
   clipboard.on("error", e => {
    // 不支持復(fù)制
     console.log("該瀏覽器不支持自動(dòng)復(fù)制");
    // 釋放內(nèi)存
    clipboard.destroy();
   });

以上就是本次介紹的全部知識(shí)點(diǎn)內(nèi)容,感謝大家對(duì)腳本之家的支持。

相關(guān)文章

最新評(píng)論

黔江区| 全椒县| 惠东县| 承德市| 齐齐哈尔市| 尚义县| 股票| 柘城县| 英德市| 高清| 德令哈市| 韶山市| 师宗县| 乐山市| 和平县| 高台县| 崇州市| 黎川县| 长治市| 海淀区| 松原市| 德钦县| 会昌县| 迁安市| 普定县| 洪雅县| 贵溪市| 高安市| 横山县| 千阳县| 明光市| 罗城| 乃东县| 高邮市| 武川县| 广汉市| 宁河县| 鄂温| 周口市| 墨竹工卡县| 禹州市|