1. <small id='7G7vl'></small><noframes id='7G7vl'>

  2. <tfoot id='7G7vl'></tfoot>
    <legend id='7G7vl'><style id='7G7vl'><dir id='7G7vl'><q id='7G7vl'></q></dir></style></legend>

      • <bdo id='7G7vl'></bdo><ul id='7G7vl'></ul>
    1. <i id='7G7vl'><tr id='7G7vl'><dt id='7G7vl'><q id='7G7vl'><span id='7G7vl'><b id='7G7vl'><form id='7G7vl'><ins id='7G7vl'></ins><ul id='7G7vl'></ul><sub id='7G7vl'></sub></form><legend id='7G7vl'></legend><bdo id='7G7vl'><pre id='7G7vl'><center id='7G7vl'></center></pre></bdo></b><th id='7G7vl'></th></span></q></dt></tr></i><div id='7G7vl'><tfoot id='7G7vl'></tfoot><dl id='7G7vl'><fieldset id='7G7vl'></fieldset></dl></div>

      如何连接我的 angular2 应用程序 javascript 文件

      时间:2023-05-29

          <tfoot id='udpy8'></tfoot>

              <small id='udpy8'></small><noframes id='udpy8'>

            1. <i id='udpy8'><tr id='udpy8'><dt id='udpy8'><q id='udpy8'><span id='udpy8'><b id='udpy8'><form id='udpy8'><ins id='udpy8'></ins><ul id='udpy8'></ul><sub id='udpy8'></sub></form><legend id='udpy8'></legend><bdo id='udpy8'><pre id='udpy8'><center id='udpy8'></center></pre></bdo></b><th id='udpy8'></th></span></q></dt></tr></i><div id='udpy8'><tfoot id='udpy8'></tfoot><dl id='udpy8'><fieldset id='udpy8'></fieldset></dl></div>
              <legend id='udpy8'><style id='udpy8'><dir id='udpy8'><q id='udpy8'></q></dir></style></legend>
                <tbody id='udpy8'></tbody>
                <bdo id='udpy8'></bdo><ul id='udpy8'></ul>
                本文介绍了如何连接我的 angular2 应用程序 javascript 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                对于我的 angular2 typescript 应用程序,我将所有 js 文件合并到一个 app.min.js 文件中,然后将该文件 System.import 到我的 index.html 页面.

                For my angular2 typescript app I concat all my js files into one app.min.js file, then System.import this file to my index.html page.

                然后,我的控制台日志中出现多个匿名 System.register 调用在同一个模块文件中错误.

                I then get a Multiple anonymous System.register calls in the same module file error in my console log.

                我将所有 Javascript 文件(不是库)放入 app.min.js 中,然后在我的 index.html 页面上使用 system.import 导入该文件以导入该 js 文件.

                I put all my Javascript files (not libraries) into app.min.js and then on my index.html page I then import the file using system.import to import that js file.

                当我将所有 Javascript 文件合并到一个文件中时,我会按照一定的顺序进行操作.

                When I concat all the Javascript files into one file I do them in a certain order.

                也许我的配置中缺少一些参考或设置?

                Maybe I'm missing some references or settings in my configs?

                这是我的 index.html 页面:

                <!DOCTYPE html>
                <html lang="en" prefix="og: http://ogp.me/ns#" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
                  <head>
                    <base href="/"></base>
                
                    <meta charset="UTF-8">
                    <meta name="fragment" content="!"/>
                    <meta content="IE=edge, chrome=1" http-equiv="X-UA-Compatible"/>
                    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=0.5, user-scalable=yes"/>
                
                
                    <!-- inject:css -->    
                       <link rel="stylesheet" href="/src/css/styles.af010955.css">    
                    <!-- endinject -->
                
                    <!-- Js libs -->    
                    <script type="text/javascript" src="https://cdn.jsdelivr.net/lodash/4.11.2/lodash.min.js"></script>
                    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
                    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>        
                    <script type="text/javascript" src="/bootstrap.js"></script>    
                
                    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-shim.min.js"></script>    
                    <script type="text/javascript" src="/safariPolyFix.js"></script>    
                    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.18.4/system.src.js"></script>   
                
                    <script>
                        System.config({
                            transpiler: 'typescript',
                            defaultJSExtensions: true,  
                            typescriptOptions: {
                                emitDecoratorMetadata: true,
                            },          
                            packages: {
                                'angular2-google-maps': {
                                  defaultExtension: 'js'
                                }
                            }
                        });       
                    </script>
                
                    <script type="text/javascript" src="/angular2_google_maps.js"></script>
                
                    <script type="text/javascript" src="https://code.angularjs.org/2.0.0-beta.0/angular2-polyfills.js"></script>
                    <script type="text/javascript" src="https://code.angularjs.org/tools/typescript.js"></script>
                    <script type="text/javascript" src="https://code.angularjs.org/2.0.0-beta.0/Rx.js"></script>
                
                    <script type="text/javascript" src="https://code.angularjs.org/2.0.0-beta.0/angular2.js"></script>
                    <script type="text/javascript" src="https://code.angularjs.org/2.0.0-beta.0/router.js"></script>
                    <script type="text/javascript" src="https://code.angularjs.org/2.0.0-beta.0/http.js"></script>  
                
                    <script type="text/javascript" src="/firebase/firebaseNew.js"></script>
                
                  </head>
                
                  <body id="container">
                
                    <app></app>
                
                    <script type="text/javascript">  
                      System.import('/app/app.min.js');
                    </script>
                
                  </body>
                </html>
                

                这是我的 gulp 文件:

                var gulp = require('gulp');
                var concat = require('gulp-concat');
                
                gulp.task('app', function() {
                    return gulp.src(['src/app/app.component.js', 'src/app/*.js', 'src/app/filters/*.js', 'src/app/models/**/*.js', 'src/app/components/**/*.js', 'src/app/services/**/*.js'])
                        .pipe(concat('app.min.js'))
                        .pipe(gulp.dest('src/app'));
                });
                
                gulp.task('default', ['app']);
                

                这是我的 tsconfig.json

                {
                  "compilerOptions": {
                    "target": "ES5",
                    "module": "system",
                    "moduleResolution": "node",
                    "sourceMap": true,
                    "emitDecoratorMetadata": true,
                    "experimentalDecorators": true,
                    "removeComments": false,
                    "noImplicitAny": false
                  },
                  "exclude": [
                    "node_modules"
                  ]
                }
                

                这是我的错误屏幕截图:

                这是浏览器控制台中的源文件:

                推荐答案

                其实你不能自己concat typescript编译器生成的js文件.

                In fact you can't concat js files by your own that are generated by the typescript compiler.

                如果您想将它们全部放在一个文件中,则需要在 tsconfig.json 文件中利用编译器的 outFile 属性:

                If you want to have all of them in a single file, you need to leverage the outFile property of the compiler in the tsconfig.json file:

                {
                  "compilerOptions": {
                    "target": "ES5",
                    "module": "system",
                    "moduleResolution": "node",
                    "sourceMap": true,
                    "emitDecoratorMetadata": true,
                    "experimentalDecorators": true,
                    "removeComments": false,
                    "noImplicitAny": false,
                    "outFile": "app.js" <-------
                  },
                  "exclude": [
                    "node_modules"
                  ]
                }
                

                这篇关于如何连接我的 angular2 应用程序 javascript 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:读取一堆 JSON 文件,转换它们并保存它们 下一篇:在 gulp 任务中很好地抛出错误

                相关文章

                最新文章

                <tfoot id='A2vWd'></tfoot><legend id='A2vWd'><style id='A2vWd'><dir id='A2vWd'><q id='A2vWd'></q></dir></style></legend>

                <i id='A2vWd'><tr id='A2vWd'><dt id='A2vWd'><q id='A2vWd'><span id='A2vWd'><b id='A2vWd'><form id='A2vWd'><ins id='A2vWd'></ins><ul id='A2vWd'></ul><sub id='A2vWd'></sub></form><legend id='A2vWd'></legend><bdo id='A2vWd'><pre id='A2vWd'><center id='A2vWd'></center></pre></bdo></b><th id='A2vWd'></th></span></q></dt></tr></i><div id='A2vWd'><tfoot id='A2vWd'></tfoot><dl id='A2vWd'><fieldset id='A2vWd'></fieldset></dl></div>

              • <small id='A2vWd'></small><noframes id='A2vWd'>

                  <bdo id='A2vWd'></bdo><ul id='A2vWd'></ul>