Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 系统配置2安装模块时出现问题。解释_Javascript_Angular_Angular Material_Systemjs - Fatal编程技术网

Javascript 系统配置2安装模块时出现问题。解释

Javascript 系统配置2安装模块时出现问题。解释,javascript,angular,angular-material,systemjs,Javascript,Angular,Angular Material,Systemjs,我最近开始学习Angular 2。有很多教程。但有一件事我仍然无法理解,那就是systemjs.config.js 我理解为什么使用它,以及它的主要目的是什么。但如何使用它来添加其他依赖项还不够清楚 我使用的是Starter存储库中的默认包。 但正如我提到的,我在添加新模块时遇到了麻烦 我曾多次尝试包含不同的模块,但几次尝试后,我放弃了 我试图找到一个好的教程或文档来解释如何在Angular 2的上下文中处理这个工具,但没有结果 目前我无法安装Material Design Lite模块 这是我

我最近开始学习Angular 2。有很多教程。但有一件事我仍然无法理解,那就是
systemjs.config.js

我理解为什么使用它,以及它的主要目的是什么。但如何使用它来添加其他依赖项还不够清楚

我使用的是Starter存储库中的默认包。 但正如我提到的,我在添加新模块时遇到了麻烦

我曾多次尝试包含不同的模块,但几次尝试后,我放弃了

我试图找到一个好的教程或文档来解释如何在Angular 2的上下文中处理这个工具,但没有结果

目前我无法安装Material Design Lite模块

这是我的
systemjs.config.js
文件

(function (global) {
    System.config({

        paths: {
            // paths serve as alias
            'npm:': 'node_modules/'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder
            app: 'app',
            '@angular-mdl/core': 'vendor/@angular-mdl/core',
            // angular bundles
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
            '@angular/material': 'npm:@angular/material/bundles/material.umd.js',
            // other libraries
            'hammerjs': 'npm:hammerjs/hammer.js',
            'rxjs': 'npm:rxjs',
            'angular2-mdl': 'vendor/angular2-mdl',
            'primeng': 'npm:primeng'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                defaultExtension: 'js'
            },
            'angular2-mdl': {main: 'bundle/angular2-mdl.js'},
            rxjs: {
                defaultExtension: 'js'
            },
            primeng: {
                defaultExtension: 'js'
            }
        }

    });
})(this);
我的
index.html

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic">
<link rel="stylesheet" href="/node_modules/material-design-lite/material.min.css">
<script src="/node_modules/material-design-lite/material.min.js"></script>
<link rel="stylesheet" href="/node_modules/material-design-icons/iconfont/material-icons.css">    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="node_modules/@angular/material/core/theming/prebuilt/deeppurple-amber.css" rel="stylesheet">
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="style.css">

但我仍然得到以下错误

模板分析错误:“mdl图标”不是已知元素:1。如果 “mdl图标”是一个角度组件,然后确认它是 这个模块。2.如果“mdl图标”


请解释如何使用此文件。或者至少是如何包括材料设计Lite模块。

“供应商”是一个通用术语,用于描述提供包装的地点,因此它可以是某种形式的CDN,或者在您的情况下是npm


首先要做的是将
vendor/
替换为
npm:
,这样它将在项目的
节点模块
文件夹中查找,而不是一个名为vendor的文件夹,它很可能不存在

仍然不知道这些东西是如何工作的。但要让它工作,请执行以下操作

(function (global) {
    System.config({

        paths: {
            // paths serve as alias
            'npm:': 'node_modules/'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder
            app: 'app',

            'angular2-mdl': 'npm:angular2-mdl/',

        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            'angular2-mdl': {main: 'bundle/angular2-mdl.js'},

        }

    });
})(this);
别忘了在你的app.module.js中导入
MdlModule

@NgModule({
    imports: [BrowserModule, MdlModule, HttpModule, MaterialModule, RoutingModule],

嘿,在你的错误中的某个地方,它应该给你它试图用来找到你的包的路径。我已经看过node_模块中的angular2 mdl;尝试将“angular2 mdl”映射的路径更改为等于“npm:angular2 mdl/bundle/angular2 mdl.js”