html5載入JS引用,html5載入js

來源:互聯網
上載者:User

html5載入JS引用,html5載入js

直接上代碼

w檔案

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


<div xmlns="http://www.w3.org/1999/xhtml" xid="window" class="window" component="$UI/system/components/justep/window/window" design="device:mobile">  
  <div component="$UI/system/components/justep/model/model" xid="model"/> 
  <h1 xid="h11" style="text:align:center;">h1</h1>
  <a component="$UI/system/components/justep/button/button"
  class="btn btn-default" onClick="importInnerBtnClick">
    <i xid="i1"></i>
    <span xid="span1">載入UI2,符合AMD規範的檔案</span>
  </a>
  <a component="$UI/system/components/justep/button/button"  class="btn btn-default"
  label="載入外網,符合AMD規範的檔案" xid="importOutterBtn" onClick="importOutterBtnClick">
     <i xid="i2"></i>
     <span xid="span2">載入外網,符合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");
}
};
});


程式中會出現兩個按鈕

引用外部js檔案成功引用網路js檔案失敗

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.