zoukankan      html  css  js  c++  java
  • 博客日记

      今天写了一些editor的代码,学了一些写框架得东西

    (function( global, factory ) {
        //应该是为了可以应用在requirejs等库中
        if ( typeof module === "object" && typeof module.exports === "object" ) {
            // For CommonJS and CommonJS-like environments where a proper window is present,
            // execute the factory and get jQuery
            // For environments that do not inherently posses a window with a document
            // (such as Node.js), expose a jQuery-making factory as module.exports
            // This accentuates the need for the creation of a real window
            // e.g. var jQuery = require("jquery")(window);
            // See ticket #14549 for more info
            module.exports = global.document ?
                factory( global, true ) :
                function( w ) {
                    if ( !w.document ) {
                        throw new Error( "orionEditor requires a window with a document" );
                    }
                    return factory( w );
                };
        } else {
            //无模块环境时
            factory( global );
        }
    
    // Pass this if window is not defined yet
    }(typeof window !== "undefined" ? window : this,function(){}));
    

      在后面的function才是自己的框架的代码,这段代码取自jquery,毕竟我还太嫩。。。

          这段代码的作用就是自己写的私有的方法和一些东西不会污染全局的环境,同时还可以,但是有一些修改了prototype的代码还是可能会改变其他的代码。

      jquery的思想大概今天了解了一些,是通过创建一个jquery对象,这个对象的功能非常强大,封装了许多的方法,这样就会使jquery开发者同样可以使用原生的js或者其他的库当然并不可以用JQuery或者$();

      每次$()都会返回一个jquery对象。而且还有优雅的链式调用。以前比较年轻,但是今天真的是觉得jqeury是一个非常优雅的库,有很多值得我们去学习的地方。

      最后,加油

  • 相关阅读:
    oracle数据库闪回执行步骤——oracle数据库回退
    10.20总结
    10.11总结
    10.10总结
    10.9总结
    10.8总结
    10.7总结
    10.6总结
    10.5总结
    10.4总结
  • 原文地址:https://www.cnblogs.com/orionwei/p/5543907.html
Copyright © 2011-2022 走看看