首页 > requirejs可以通过http加载js吗

requirejs可以通过http加载js吗

requirejs可以通过http加载js吗,
比如:require("http://api.baidu.com/map/1.2.js")


支持的!
支持与否,为啥不自己试试呢?

但是不是你那样写的,要先配置。

require.config({
  paths:{
    'baiduapi':'http://api.baidu.com/map/1.2.js'
  }
});
//调用
require('baiduapi');

可以参考这里:
http://requirejs.org/docs/api.html#confi...

There may be times when you do want to reference a script directly and not conform to the "baseUrl + paths" rules for finding it. If a module ID has one of the following characteristics, the ID will not be passed through the "baseUrl + paths" configuration, and just be treated like a regular URL that is relative to the document:
Ends in ".js".
Starts with a "/".
Contains an URL protocol, like "http:" or "https:".

顺便推荐一下,我写的模块加载,实现原理和require,seajs之类的不一致。


https://github.com/donghanji/pm

也是支持url的方式加载模块的。

【热门文章】
【热门文章】