首页 > 代码库 > require() 方法讲解

require() 方法讲解

require.config({
  paths:{
    "jquery":"jquery.min",
    "underscore":"underscore.min",
    "backbone":"backbone.min"
  }
});
//逐一指定路径
require.config({
  paths:{
    "jquery": "lib/jquery.min",
    "underscore": "lib/underscore.min",
    "backbone": "lib/backbone.min"
  }
})
//直接改变基目录(baseURL)
require.config({
  baseUrl:"js/lib",
  paths:{
    "jquery": "jquery.min",
    "underscore": "underscore.min",
    "backbone": "backbone.min"
  }
})
//直接指定网址
 require.config({
  path:{
    "jquery":"https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min"
  }
})

http://www.ruanyifeng.com/blog/2012/11/require_js.html

写的很好

 

require() 方法讲解