把jQuery的类、插件封装成seajs的模块的方法

复制代码 代码如下:

define(function () {

//这里放置jquery代码 把你喜欢的jquery版本放进来就好了


return $.noConflict();
});

调用方法:
这样引进就可以像以前一样使用jquery

复制代码 代码如下:

define(function (require, exports, module) {
    var $ = require('./js/jquery');
 

// $(document).ready(function () {
     //   $("tr").wyhinterlaced({ "odd": "red", "even": "blue" });
     //   $("tr").wyhhover();
   // })
});


二、把jquery的类封装成seajs模块

复制代码 代码如下:

define(function (require, exports, module) {

var $ = require("../js/jquery");


    var weekday = new Array(7)
    weekday[0] = "星期一";
    weekday[1] = "星期二";
    weekday[2] = "星期三";
    weekday[3] = "星期四";
    weekday[4] = "星期五";
    weekday[5] = "星期六";
    weekday[6] = "星期日";

function GetType(arg) {
        var today = new Date();
        var year = today.getFullYear();
        var month = today.getMonth() + 1;
        var td = today.getDate();
        var d = weekday[today.getDay() - 1];
        var h = today.getHours();
        var m = today.getMinutes();
        var s = today.getSeconds();
        switch (arg) {
            case 1:  //2013-09-09 09:31:56
                return year + "-" + month + "-" + td + "  " + h + ":" + m + ":" + s; break;
            case 2:  //2013-09-09 (星期一) 09:31:56
                return year + "-" + month + "-" + td + " (" + d + ") " + h + ":" + m + ":" + s; break;
            case 3:  //09-09-2013 09:31:56
                return month + "-" + td + "-" + year + "  " + h + ":" + m + ":" + s; break;
            case 4:  //09-09-2013 星期一 09:31:56
                return month + "-" + td + "-" + year + " (" + d + ") " + h + ":" + m + ":" + s; break;
            case 5:  //2013年09月09日 09时31分秒56
                return year + "年" + month + "月" + td + "日  " + h + "时" + m + "分" + s + "秒"; break;
            case 6:  //2013年09月09日 星期一 09时31分秒56
                return year + "年" + month + "月" + td + "日  (" + d + ")  " + h + "时" + m + "分" + s + "秒"; break;
        }
    };

/*******************************************************
    /*函数名:GetTime
    /*参数:数值(包括整形浮点型都可以,浮点型会做四舍五入处理,如果不是数字,
    函数将采用默认的时间格式返回!时间样式有15【1-15是有效的时间样式
    超出或小于都将采用默认的样式 样式1】中)
    /*功能  获取当前的系统时间 可定制格式
    *******************************************************/

function  GetTime(arg) {
        if (!isNaN(arg)) {
            var num = Math.round(arg);

if (num < 7 && num > 0) {
                return GetType(num);
            }
            else {
                var str;
                var str2;
                switch (num) {
                    case 0: return GetType(1); break;
                    case 7: str = GetType(2); return str.replace(/星期/, ""); break;
                    case 8: str = GetType(1); return str.replace(/-/, "https://www.jb51.net/").replace(/-/, "https://www.jb51.net/"); break;
                    case 9: str = GetType(2); return str.replace(/-/, "https://www.jb51.net/").replace(/-/, "https://www.jb51.net/");
                    case 10: str = GetType(2); str2 = str.replace(/-/, "https://www.jb51.net/").replace(/-/, "https://www.jb51.net/"); return str2.replace(/星期/, ""); break;
                    case 11: str = GetType(4); return str.replace(/星期/, ""); break;
                    case 12: str = GetType(3); return str.replace(/-/, "https://www.jb51.net/").replace(/-/, "https://www.jb51.net/"); break;
                    case 13: str = GetType(4); return str.replace(/-/, "https://www.jb51.net/").replace(/-/, "https://www.jb51.net/");
                    case 14: str = GetType(4); str2 = str.replace(/-/, "https://www.jb51.net/").replace(/-/, "https://www.jb51.net/"); return str2.replace(/星期/, ""); break;
                    case 15: str = GetType(6); return str.replace(/星期/, "");
                    default: return GetType(1); break;
                }
            }
        }
        else {
            return GetType(1);
        }
    };

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjxwps.html