代码之家  ›  专栏  ›  技术社区  ›  Mike

ES6:如何导入和导出模块以及从控制台保持访问权限

  •  0
  • Mike  · 技术社区  · 4 年前

    通常我可以从控制台触发UIkit函数,比如:

    UIkit.alert('.myalert').close();
    

    编译此文件时,我不再可以通过控制台访问:

    import UIkit from 'uikit';
    import Icons from './uikit/uikit-icons';
    UIkit.use(Icons);
    
    import Myfunction from './myfunction';
    
    document.addEventListener('DOMContentLoaded', () => {
        Myfunction('something');
    })
    

    export default { UIkit };
    
    2 回复  |  直到 4 年前
        1
  •  1
  •   Anurag Srivastava    4 年前

    添加 window.UIkit = UIkit 之后 import

        2
  •  0
  •   Vyacheslav Palamar    4 年前

    我相信一定是 export default UIkit; 因为现在导出的对象 UIkit 但你也需要进口 UIkit公司 myfunction 也。