DefaultExtension在Angular 2应用程序中不起作用
发布时间:2020-12-17 07:17:40 所属栏目:安全 来源:网络整理
导读:我正在尝试使用TypeScript设置基本的Angular 2应用程序.但是我被卡住了,因为SystemJS似乎没有使用defaultExtension:’js’选项做任何事情. 我的index.html看起来像这样: !DOCTYPE htmlhtml lang="en"head base href="/test/" meta charset="UTF-8" titleTe
我正在尝试使用TypeScript设置基本的Angular 2应用程序.但是我被卡住了,因为SystemJS似乎没有使用defaultExtension:’js’选项做任何事情.
我的index.html看起来像这样: <!DOCTYPE html> <html lang="en"> <head> <base href="/test/"> <meta charset="UTF-8"> <title>Test</title> <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet"> <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="node_modules/rxjs/bundles/Rx.js"></script> <script src="node_modules/angular2/bundles/angular2.dev.js"></script> <script src="node_modules/angular2/bundles/router.dev.js"></script> <script> System.config({ packages: { app: { format: 'register',defaultExtension: 'js',} } }); System.import('backend/app/boot') .then(null,console.error.bind(console)); </script> </head> <body> <app>Loading</app> </body> </html> 但是这会给我以下错误: GET http://localhost:1122/test/backend/app/boot 404 (Not Found) 我可以在System.import命令中将.js扩展名添加到路径中,以便它看起来像这样: System.import('backend/app/boot.js') 然后它能够??找到boot.js,但然后它抱怨它找不到app.component.所以基本上我必须为该导入添加一个.js扩展名,以及我将在我的应用程序中添加的所有其他组件. 我不认为这是我必须要解决的问题.那么我该如何修复这个System.import问题呢?看起来它忽略了defaultExtension:’js’由于某种原因.
您将js设置为应用程序包的默认扩展名,但您的代码位于后端/应用程序,而不是应用程序,要么删除后端文件夹,要么修复程序包配置.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |