代码之家  ›  专栏  ›  技术社区  ›  Симеон Симеонов

从bower_组件加载系统

  •  0
  • Симеон Симеонов  · 技术社区  · 8 年前

     <script src="./bower_components/systemjs/build/system.min.js"></script>
     <script src="./scripts/system-config.js"></script>
    
    SystemJS.config({
        transpiler: 'plugin-babel',
        map: {
            //system transpiler
            'plugin-babel': './bower_components/systemjs-plugin-babel/plugin-babel.js',
            'systemjs-babel-build': './bower_components/systemjs-plugin-babel/systemjs-babel-browser.js',
    
            //app scripts
            'main': './scripts/main.js',
            'requester': './scripts/requester.js',
            'templates': './scripts/templates.js',
            'data': './scripts/data.js',
    
            //controllers
            'home': '../controllers/home.js',
            'login-form': '../controllers/login-form.js',
    
            //js libraries
            'jquery': './bower_components/jquery/dist/jquery.js',
            'navigo': './bower_components/navigo/lib/navigo.min.js',
            'handlebars': './bower_components/handlebars/dist/handlebars.js',
        }
    });
    
    SystemJS.import('./scripts/main.js').then(x => console.log(x), x => console.log(x));
    
    1 回复  |  直到 8 年前
        1
  •  1
  •   Tom M    8 年前

    你可能犯了与我在试图重现错误时相同的错误。

    您使用以下命令安装了SystemJS:

    bower install systemjs
    

    https://bower.io/search/ 并搜索systemjs。你会发现第一个包裹上写着

    系统js公司 systemjs系统

    在install命令中添加一个点。

    bower install system.js