直接上代码

w文件

<?xml version="1.0" encoding="UTF-8"?

>


<div xmlns="http://www.w3.org/1999/xhtml" x>  
  <div component="$UI/system/components/justep/model/model" x/> 
  <h1 x>h1</h1>
  <a component="$UI/system/components/justep/button/button"
  class="btn btn-default" onClick="importInnerBtnClick">
    <i x></i>
    <span x>载入UI2,符合AMD规范的文件</span>
  </a>
  <a component="$UI/system/components/justep/button/button"  class="btn btn-default"
  label="载入外网,符合AMD规范的文件" x>
     <i x></i>
     <span x>载入外网,符合AMD规范的文件</span>
  </a>
</d


JS文件

define(function(require){
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");

var Model = function(){
this.callParent();
};
   Model.prototype.importInnerBtnClick=function(event){
  //载入UI2下,符合AMD规范的文件
  var path="./AMD2";
  require([path],function(m){
  m.fnOfAMD2();
  });
  
   }
   Model.prototype.importOutterBtnClick=function(event){
  var path="http://localhost:8080/cn/wp-content/uploads/2015/04/outterAMD2.js"
       require([path],function(m){
      m.fnOfOutterAMD2();
       })
   }
return Model;
});


须要引用的JS文件

define(
function(require){
return{
fnOfAMD2:function(){
alert("hello AMD2");
}
};
});


程序中会出现两个button

引用外部js文件成功引用网络js文件失败

相关文章:

  • 2022-12-23
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
  • 2021-07-30
  • 2021-06-04
猜你喜欢
  • 2022-01-05
  • 2022-02-06
  • 2022-02-09
  • 2021-10-21
  • 2021-10-13
  • 2022-02-15
  • 2022-12-23
相关资源
相似解决方案