日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

AngularJs2与AMD加载器(dojo requirejs)集成

發布時間:2025/7/14 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 AngularJs2与AMD加载器(dojo requirejs)集成 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

現在是西太平洋時間凌晨,這個問題我鼓搗了一天,都沒時間學英語了,英語太差,相信第二天我也看不懂了,直接看結果就行。
核心原理就是require在AngularJs2編譯過程中是關鍵字,而在瀏覽器里面運行時候AngularJs2不會去關心require方法。所以只要在原始的ts代碼中不出現require就沒問題。所以在AMD的加載器加載完畢之后,立即用一個全局變量保存,在AngularJs2的代碼中使用這個全局變量在做加載器。
Because require is a key word of Angular, RequireJs will conflict with Angularjs.
The reason angular use commonjs modular specification, it need to compile to js for run in browsers.
If you used require in code angularjs2 , the expression will be compiled to another style:

require(['dojo/_base/html'], (html) => {console.log(html);}); var html = __webpack_require__(['dojo/_base/html']); console.log(html);

But if you the code in runing, the require will works fine.

This means Angularjs2 never replace the require when your app run in browsers.
So there have a perfect way to integrate requireJs within AngularJs2.

<script>dojoConfig = {async: true,parseOnLoad: false}</script><script src="//js.arcgis.com/3.17/"></script><script type="text/javascript">dojoRequire = require;</script>

轉載于:https://www.cnblogs.com/dojo-lzz/p/5688440.html

總結

以上是生活随笔為你收集整理的AngularJs2与AMD加载器(dojo requirejs)集成的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。