首页 > 解决方案 > javascript和html中的Systemjs配置错误

问题描述

我想在我的 javascript 和 html 中使用模块。当我使用版本 5 的 systemjs 时,出现错误,在 github 中我看不到配置步骤。如果我从下面的代码中删除 System.config,那时我会遇到 CORS 问题。

  1. 我必须使用什么包来运行 javascript 和 html 中的模块
  2. 如何设置最新版本的配置

            <!-- <script src="node_modules/traceur/bin/traceur.js"></script>
            <script src="node_modules/systemjs/dist//system.js"></script> -->
            <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/5.0.0/system.js"></script>
        </head>
    
        <body>
            <script>
    //Configuration 
                System.config({
                    'meta': {
                        './js/*.js': {
                            format: 'esm'
                        }
                    }
                });
                System.import('./js/app.js');
            </script>
    

        I am getting Error : index.html:18 Uncaught TypeError: System.config is not a function. if I removed system.config i am getting Error : Unable to resolve bare specifier "js/app.js" from file:///C:/Train/ES6/systemjss/ at throwBare (system.js:184)     at resolveImportMap (system.js:180)     at system.js:734
    

标签: systemjs

解决方案


推荐阅读