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


相关推荐

  • 纯HTML CSS制作导航栏 下拉菜单

    纯HTML CSS制作导航栏 下拉菜单纯HTMLCSS制作导航栏下拉菜单

    2022年5月28日
    40
  • python drawcontours_2021-02-15 Python OpenCV drawContours()函数

    python drawcontours_2021-02-15 Python OpenCV drawContours()函数drawContours image contours contourIdx color thickness 1 lineType LINE 8 hierarchy noArray maxLevel INT MAX offset None 该函数用于绘制轮廓线或者填充轮廓线 如果参数 那么就绘制轮廓线 如果参数 则填充轮廓线内的区域 参数 image 目标图像 contour

    2025年8月30日
    10
  • datagrip mac 激活码_在线激活2022.02.16

    (datagrip mac 激活码)2021最新分享一个能用的的激活码出来,希望能帮到需要激活的朋友。目前这个是能用的,但是用的人多了之后也会失效,会不定时更新的,大家持续关注此网站~https://javaforall.net/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~FZ…

    2022年4月1日
    72
  • 模拟视频的接头的端口_网络摄像头改模拟接口

    模拟视频的接头的端口_网络摄像头改模拟接口这些接口均传输模拟信号一、CVBS(RCA接口)RCA接口是最简单、最原始的视频接口,也称做复合视频信号(CVBS)接口。他传输的是复合视频信号,传输介面是一根普通的视频线。一般由红、黄、白三色组成,黄色的为视频信号,白色的为左声道音频信号,红色的为右声道音频信号。注:RCA输入输出是车载功放最主要的音频输入和输出接口,当然还有其他接线柱等接口。车载功放…

    2025年6月12日
    4
  • hibernate执行原生sql_hibernate的find方法

    hibernate执行原生sql_hibernate的find方法如果查询返回多个值用list()方法[java] viewplaincopyprint?public void testQuery(){          Configuration config = new Configuration().configure();          SessionFactory factory =

    2025年8月27日
    18
  • 详谈如何定制自己的博客园皮肤

    详谈如何定制自己的博客园皮肤前言最近,有很多博客园的朋友给我留言或私信,询问我的博客背景是如何做的。不是我敝帚自珍,而是由于内容较多,一一回复实在是太费劲。没有及时答复的朋友,请见谅。我在这里做一次集中式分享,如果有喜欢的

    2022年7月1日
    24

发表回复

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

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