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


相关推荐

  • BeanUtils_BeanUtils

    BeanUtils_BeanUtils1.beanUtils工程1.工程目录2.需要的jar包:commons-beanutils-1.9.3.jarcommons-collections-3.2.2.jarcommons-logging-1.2.jar3.转换器DateConverter.java:packagecom.my.model;importjava.text.ParseException;

    2022年9月12日
  • unsigned int在c语言中是什么意思_尿液报告里面vc什么意思

    unsigned int在c语言中是什么意思_尿液报告里面vc什么意思在一个项目中,要求用VC6写DLL,其中有字段要求用UINT16,vc6中没有UINT16。UINT16,无符号int要16位,占2字节(1字节byte=8位bit),1111111111111111,表示范围0~65535。在此,我想到用别的类型代替它,并对范围测试,下面用vc6随便建一个程序,添加一个button双击添加代码:000000000000000

    2022年8月15日
  • c++中vector的用法详解_vector>初始化

    c++中vector的用法详解_vector>初始化vector()的用法概念vector是向量类型,它可以容纳许多类型的数据,如若干个整数,所以称其为容器。vector是C++STL的一个重要成员,使用它时需要包含头文件:#include<vector>;一、vector的初始化(1)vector<int>a(10);//定义了10个整型元素的向量(尖括号中为元素类型名,它可以是任何合法的数据类型),但没有给出初值,其值是不确定的。测试#include<iostream>#include&

    2022年9月15日
  • FileSystemWatcher 监控文件变化

    FileSystemWatcher 监控文件变化本文测试了FileSystemWatcher类监控文件变化。usingSystem;usingSystem.Security.Permissions;usingSystem.IO;namespaceConsoleApp1{publicclassFileStateWatcher{[PermissionSet(Secu…

    2022年6月16日
  • navicat premium 激活码_最新在线免费激活

    (navicat premium 激活码)本文适用于JetBrains家族所有ide,包括IntelliJidea,phpstorm,webstorm,pycharm,datagrip等。IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html…

    2022年3月26日
  • 引入js和css文件的总结

    1.用script标签引入javascript时,浏览器对于javascript的加载某些是并行的,某些是串行的,如IE8,Chorme2和firefox3都是串行加载的。2.charset编码也就是

    2021年12月20日

发表回复

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

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