clipboard使用Require自动复制「建议收藏」

clipboard使用Require自动复制「建议收藏」由于没有使用过require,在微擎人人商城中遇到了一个需要自动复制内容的功能。头疼了一番。varversion=+newDate();varmyconfig={path:’../addons/ewei_shopv2/static/js/’,alias:{‘jquery’:’dist/jquery/jquery-1.11.1.min’,’jquery.form’:’dist/jquery/jquery.form’,

大家好,又见面了,我是你们的朋友全栈君。

由于没有使用过require,在微擎人人商城中遇到了一个需要自动复制内容的功能。头疼了一番。

var version = +new Date();
var myconfig = {
    path: '../addons/ewei_shopv2/static/js/',
    alias: {
        'jquery': 'dist/jquery/jquery-1.11.1.min',
        'jquery.form': 'dist/jquery/jquery.form',
        'jquery.gcjs': 'dist/jquery/jquery.gcjs',
        'jquery.validate': 'dist/jquery/jquery.validate.min',
        'jquery.nestable': 'dist/jquery/nestable/jquery.nestable',
        'jquery.qrcode':'../dist/jquery/jquery.qrcode.min',
        'bootstrap': 'dist/bootstrap/bootstrap.min',
        'bootstrap.suggest': 'dist/bootstrap/bootstrap-suggest.min',
        'bootbox': 'dist/bootbox/bootbox.min',
        'sweet': 'dist/sweetalert/sweetalert.min',
        'select2': 'dist/select2/select2.min',
        'jquery.confirm': 'dist/jquery/confirm/jquery-confirm',
        'jquery.contextMenu': 'dist/jquery/contextMenu/jquery.contextMenu',
        'switchery': 'dist/switchery/switchery',
        'echarts': 'dist/echarts/echarts-all',
        'echarts.min': 'dist/echarts/echarts.min',
        'toast': 'dist/jquery/toastr.min',
        'clipboard': 'dist/clipboard.min',
        'tpl': 'dist/tmodjs',
        'daterangepicker': 'dist/daterangepicker/daterangepicker',
        'datetimepicker': 'dist/datetimepicker/jquery.datetimepicker',
        'ueditor': 'dist/ueditor/ueditor.parse.min',
        'tooltipbox': 'dist/tooltipbox',
        'moment':'dist/moment/moment'

    },
    map: {
        'js': '.js?v=' + version,
        'css': '.css?v=' + version
    },
    css: {
        'jquery.confirm': 'dist/jquery/confirm/jquery-confirm',
        'sweet': 'dist/sweetalert/sweetalert',
        'select2': 'dist/select2/select2,dist/select2/select2-bootstrap',
        'jquery.nestable': 'dist/jquery/nestable/nestable',
        'jquery.contextMenu': 'dist/jquery/contextMenu/jquery.contextMenu',
        'daterangepicker': 'dist/daterangepicker/daterangepicker',
        'datetimepicker': 'dist/datetimepicker/jquery.datetimepicker',
        'ueditor': 'dist/ueditor/themes/default/css/ueditor.min',
        'switchery': 'dist/switchery/switchery'
    }
    , preload: ['jquery']

};

这个配置文件中已经定义了 cliboard,然后在使用的地方写入下面的代码:

require(['clipboard'], function(Clipboard){
        var koulingStr = '{$info[kouling]}';
        var videoElem = document.getElementById('video01');
       $("#btnPlayer").click(function(){
           if(videoElem.paused){
               videoElem.play();
               $("#btnPlayer img").hide();
           }else{
               videoElem.pause();
               $("#btnPlayer img").show();
           }

           var clipboard = new Clipboard('#kouling',{
               text:function(e){
                   return koulingStr;
               }
           });
           clipboard.on('success', function(e) {
               console.log('copy ok');
           });
       });
        //var clipboard = new Clipboard(document.getElementById('kouling'));


    })

这个clipboard是不能自动触发的,必须需要一个事件去触发他。这里用的是播放事件 。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/159276.html原文链接:https://javaforall.net

(0)
上一篇 2022年7月14日 下午9:16
下一篇 2022年7月14日 下午9:36


相关推荐

  • Textmate调试Python「建议收藏」

    Textmate调试Python「建议收藏」转http://phaibin.72pines.com/2011/08/11/textmate%E8%B0%83%E8%AF%95python/[code="java"]Textmate调试Python要让Textmate调试Python的时候在光标停在编辑器里面,类似XCode的效果,需要安装PdbTextMateSupport。方法是:sudoeasy_installP…

    2022年7月12日
    32
  • 常用的jquery鼠标事件_html5回到顶部

    常用的jquery鼠标事件_html5回到顶部jQuery-doubleTap是一款非常有用的鼠标双击事件或移动设备的触摸双击事件检测jQuery插件。该插件通过对“click”和“touch”的简单代码优化来实现鼠标双击或触摸双击事件的检测。使用方法要检测双击事件需要在页面中引入jQuery和jquery-doubleTap.js文件。初始化插件jquery-doubleTap.js的实现代码非常简单:首先判断是鼠标点击事件还是触摸点击事件…

    2022年10月1日
    4
  • git命令大全(非常齐全)[通俗易懂]

    git命令大全(非常齐全)[通俗易懂]git命令大全

    2022年7月14日
    17
  • JVM 内存模型概述

    JVM 内存模型概述Java虚拟机在执行Java程序的过程中会把它所管理的内存划分为若干个不同的数据区域,这些数据区域都有各自的用途,以及创建和销毁的时间,并且它们可以分为两种类型:线程共享的方法区和堆,线程私有的虚拟机栈、本地方法栈和程序计数器。在此基础上,我们探讨了在虚拟机中对象的创建和对象的访问定位等问题,并分析了Java虚拟机规范中异常产生的情况。

    2022年6月12日
    35
  • Mac PhpStorm2017.3 快速激活

    Mac PhpStorm2017.3 快速激活本人亲测可用我也是刚刚激活的 nbsp 所以需要的小伙伴可以放心使用试用期的用户可在 PhpStorm 菜单栏 gt Help gt Register 打开 http idea imsxm com nbsp http 114 215 133 70 41017 nbsp http mcpmcc com 1017 nbsp http idea pjoc pub nbsp http jetbrains tenc

    2026年3月26日
    2
  • android toast_Android Toast

    android toast_Android ToastandroidtoastToastmessageisusefultoshownotificationforsmalltimeinandroidapp.Inthistutorial,we’lldiscussandimplementandroidToastmessageexample.Toast消息对在Android应用中显示少量通知非常有用。在本教…

    2025年11月7日
    5

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号