zoukankan      html  css  js  c++  java
  • seajs第二节,seajs各模块依赖关系

    index.html

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>seaJS学习第二节</title>
      //加上 seajsnode 值,可以让 sea.js 直接获取到自身路径,而不需要通过其他机制去自动获取。这对性能和稳定性会有一定提升,推荐默认都加上。 <script src="modules/sea/sea.js" id="seajsnode"></script> <script> seajs.use('./static/demo1/demoFn1.js',function(ex){ ex.show(); }); </script> </head> <body> </body> </html>

    demo1/demoFn1.js依赖demo2/demoFn1.js

    demo1/demoFn1.js

    define(function(require,exports,module){
        //注意require根目录是demoFn1.js所在目录,如果要关联的js文件是不在这个目录里,就要跳出去找
        var demo2 = require('./../../static/demo2/demoFn1.js').demo2; //require : 模块之间依赖的接口
        function show(){
            alert(demo2);
        }
        exports.show = show;
    });

    demo2/demoFn1.js

    define(function(require,exports,module){
        var demo2 = '我是demo2中声明的变量';
        exports.demo2 = demo2;  //exports : 对外提供接口对象
    });
  • 相关阅读:
    又是运行不到main的问题
    stlink问题
    AD7124踩过的坑
    stm32上调试AD5410
    linux读xml文件问题
    stm8问题记录
    430 仿真器 问题
    虚拟机VMware显示“内部错误”的解决方法
    VS2008 如何设置字体大小?
    Hyperledger Indy项目
  • 原文地址:https://www.cnblogs.com/fan-fan/p/3722522.html
Copyright © 2011-2022 走看看