[英]ES6: How to Import and Export modules and keep access from console
通常我可以從控制台觸發 UIkit 功能,例如:
UIkit.alert('.myalert').close();
我有一個使用 UIkit 和一個虛擬函數的小例子。 編譯時,我不再可以通過控制台訪問:
import UIkit from 'uikit';
import Icons from './uikit/uikit-icons';
UIkit.use(Icons);
import Myfunction from './myfunction';
document.addEventListener('DOMContentLoaded', () => {
Myfunction('something');
})
我添加了這個來導出 UIkit,但沒有運氣:
export default { UIkit };
import
后添加window.UIkit = UIkit
我相信它必須是export default UIkit;
因為現在你導出一個對象, UIkit
是它的關鍵。 但是您還需要將UIkit
導入到myfunction
中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.