SystemJS是萬能動態模組載入器
SystemJS:systemjs/systemjs · GitHub是一個通用Javascript模組載入器,可以在瀏覽器和NodeJS中載入ES6模組 AMD CommonJS 和全域性指令碼。
瀏覽器中使用:
上面app/app.js程式碼:
模組的格式會在System.register中自動探測。
載入ES6:
app/es6-file.js:
在NodeJS使用:首先安裝SystemJS:
npm install systemjs
載入模組類似瀏覽器:
瀏覽器中使用:
// Identical to writing System.baseURL = ... System.config({ // set all requires to "lib" for library code baseURL: '/lib/', // set "app" as an exception for our application code paths: { 'app/*': '/app/*.js' } }); System.import('app/app') <p class="indent"> |
上面app/app.js程式碼:
// relative require for within the package require('./local-dep'); // -> /app/local-dep.js // library resource var $ = require('jquery'); // -> /lib/jquery.js // format detected automatically console.log('loaded CommonJS'); <p class="indent"> |
模組的格式會在System.register中自動探測。
載入ES6:
app/es6-file.js:
export class q { constructor() { this.es6 = 'yay'; } } <p class="indent"> |
System.import('app/es6-file').then(function(m) { console.log(new m.q().es6); // yay }); <p class="indent"> |
在NodeJS使用:首先安裝SystemJS:
npm install systemjs
載入模組類似瀏覽器:
var System = require('systemjs'); // loads './app.js' from the current directory System.import('./app').then(function(m) { console.log(m); }); <p class="indent"> |
相關文章
- OrchardCore 如何動態載入模組?
- nginxphp動態編譯載入模組.NginxPHP編譯
- linux核心動態載入模組Linux
- 模組載入器
- drozer模組的編寫及模組動態載入問題研究
- Webpack模組載入器Web
- Helloworld 驅動模組載入
- 如何動態匯入ECMAScript模組
- 動手實現一個AMD模組載入器(三)
- 動手實現一個AMD模組載入器(二)
- 動手實現一個AMD模組載入器(一)
- (十三)自動載入新模組
- ElementUI級聯選擇器動態載入DemoUI
- AngularJs動態載入模組和依賴注入簡單介紹AngularJS依賴注入
- vue 動態載入元件Vue元件
- Java動態載入類Java
- UEFI載入程式 & 驅動模組化
- Angular中懶載入一個模組並動態建立顯示該模組下宣告的元件Angular元件
- Nginx 動態模組 nginx-mod-http-image-filter 載入失敗解決NginxHTTPFilter
- 動態載入UserControl
- 使用dlopen載入動態庫
- ListView動態載入資料View
- QLibrary 載入動態庫
- vue 動態載入組建Vue
- goloader - golang動態載入Golang
- 熱更新--動態載入frameworkFramework
- 動態庫載入過程
- 動態載入APK原理分享APK
- 動態載入JS和CSSJSCSS
- 動態載入JS的方法JS
- 動態載入!dom應用!
- python動態載入(三)Python
- 指令碼的動態載入指令碼
- IT真的是萬能的嗎?
- 一個簡單的JavaScript模組載入器JavaScript
- js動態載入實現提高網頁載入速度JS網頁
- EasyUI Jquery 動態載入樹,點選節點載入UIjQuery
- 利用nginx做後臺伺服器的動態載入和負載均衡Nginx伺服器負載