Giter Site home page Giter Site logo

[bug] seajs config base and etc. about seajs HOT 3 CLOSED

seajs avatar seajs commented on June 11, 2024
[bug] seajs config base and etc.

from seajs.

Comments (3)

lifesinger avatar lifesinger commented on June 11, 2024

第一个问题,要更改 base 时,建议最好设置为绝对路径,比如 http://a.tbcdn.cn/js/app/xx/
非绝对路径时,和页面地址还有关系,比如:

assets/
  js/
    libs/
      seajs.js
      jquery.js
      ...
    init.js
    hello.js
  css/
test.html

seajs.config({
  base: 'assets/js/'
 });

后,在 test.html 引用时,base 指向 http://your.com/path/to/assets/js/

建议让 base 始终指向 sea.js 所在目录
自己写的模块间,用相对路径引用,这样简单一致。

from seajs.

lifesinger avatar lifesinger commented on June 11, 2024

第二个问题,应该用 require,去掉 module.load 即可

假设有一个模块,必须依赖 a 和 b,在某些条件下依赖 c
则应该:

define(function(require, exports, module) {
  var a = require('a');
  var b = require('b');

  if(some_condition) {
    module.load('c', function(c) {
      c.doSomeCoolThing();
    });
  }

 exports.xx = 'xx';
});

module.exports 应该不能放在 module.load 的回调里,因此是同步执行,需要立刻返回的。放在 module.load 里,是异步的,异步回调里,一般不要去修改 module.exports

from seajs.

jiahao1110 avatar jiahao1110 commented on June 11, 2024

有了约定好办事!。。

from seajs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.