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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 座IO理解力

    座IO理解力

    2022年1月13日
    37
  • 交叉编译lrzsz

    交叉编译lrzsz参考:https://blog.csdn.net/linucos/article/details/5582979https://blog.csdn.net/wangzhen209/article/details/32713715https://blog.csdn.net/zijie_xiao/article/details/50934279步骤:获取源码:https://www…

    2022年6月23日
    38
  • 是否可以将频谱分析仪当做网络分析仪使用?[通俗易懂]

    是否可以将频谱分析仪当做网络分析仪使用?[通俗易懂]PSD测量值通常以Vrms2/Hz或Vrms/rtHz为单位(这里的rtHz指的是平方根赫兹)。或者,PSD也可以采用dBm/Hz为单位。PSA、ESA、856XE/EC或859XE等频谱分析仪均可通过噪声标记对功率谱密度进行测量。矢量信号分析仪比如89600S或89400,直接就有PSD测量数据类型。 在频谱分析仪上最简便的测量方法(测量结果以Vrms/rtHz为单位)就是: 在振幅菜单中选择以伏特为单位的振幅(AMPLITUDE[硬键]>More>YAxis

    2022年8月11日
    5
  • 修改idea的背景颜色_ps更换证件照背景颜色

    修改idea的背景颜色_ps更换证件照背景颜色在Idea里面修改背景颜色1、点击左上角File,然后找到Settings2、搜索框搜索Font然后后找到Appearance设置右面的Theme即可改变为想要的背景色

    2022年8月26日
    8
  • linux命令保存并退出_vim退出命令

    linux命令保存并退出_vim退出命令如何快速保存退出vim在普通模式(进入vim时的模式)下按shift+zz

    2022年8月24日
    7
  • 单片机好学还是plc好学_单片机出路

    单片机好学还是plc好学_单片机出路相信很多学电气工程专业的都会学习PLC,我当初也是电气工程专业,主要学的三菱PLC,后面也玩了下西门子的。当时觉得还挺神奇,也对编程比较感兴趣,不过学校学得太简单了,基本让你编个梯形图控制电机就算是毕业了。后来我就转去做单片机开发了,感觉比PLC更好玩,因为成本低,灵活性也高,可玩性自然也更高。最近我们无际单片机编程也有几个学员是做PLC转行过来学单片机的。我没从事过PLC的工作,根据他们描述,PLC的工资其实也还行,基本也能过万,但是就是出差太频繁,一年300天在外面出差。如果是单身寡

    2022年8月31日
    2

发表回复

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

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