角度2材质中的制表符组未在底部显示条带

时间:2017-09-25 22:20:06

标签: angular angular-material angular-material2

的index.html

<!DOCTYPE html>
<html>

<head>
    <base href="/">
    <title>test website</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="styles.css">


    <script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.js"></script>

    <link href="https://unpkg.com/@angular/material/prebuilt-themes/indigo-pink.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

    <!-- Polyfills -->
    <script src="node_modules/core-js/client/shim.min.js"></script>

    <script src="node_modules/zone.js/dist/zone.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>

    <script src="systemjs.config.js"></script>
    <script>
        System.import('main.js').catch(function(err) {
            console.error(err);
        });
    </script>
</head>

<body>
    <my-app>Loading...</my-login>
</body>

</html>

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 bundles
            '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
            '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
            '@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/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.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/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
            '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
            '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
            '@angular/material': 'npm:@angular/material/bundles/material.umd.js',
            '@angular/cdk': 'npm:@angular/cdk/bundles/cdk.umd.js',

            // other libraries
            'rxjs': 'npm:rxjs',
            'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: './main.js',
                defaultExtension: 'js',
                meta: {
                    './*.js': {
                        loader: 'systemjs-angular-loader.js'
                    }
                }
            },
            rxjs: {
                defaultExtension: 'js'
            }
        }
    });
})(this);

我正在使用 angular 4.3.1 angular-material 2.0.0-beta.8 angular-cdk 2.0.0-beta.8 < /强>

app.module.ts

从&#39; @ angular / material&#39;中导入{MaterialModule}; 从&#39; @ angular / platform-b​​rowser / animations&#39;中导入{BrowserAnimationsModule};

import { AppComponent }         from './app.component';

@NgModule({
  imports: [
    ....
    ....
    MaterialModule,
    BrowserAnimationsModule
  ],
  declarations: [
    AppComponent,
    ....
    ....
  ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

xyz.html

<div class="q-payment-container">
    <md-tab-group>
        <md-tab label="Tab 1">Content 1</md-tab>
        <md-tab label="Tab 2">Content 2</md-tab>
    </md-tab-group>

</div>

这是输出图像here

在此图片中,它会创建标签,点击后会更改标签,但不知何故,它不会在标签底部显示紫色条。代码中是否有任何遗漏?

1 个答案:

答案 0 :(得分:0)

您还需要导入Angular Material组件的特定模块。例如,对于标签,您需要像这样导入MdTabsModule

import { MdTabsModule } from '@angular/material';

您可以在api标签中找到每个Angular Material组件的要求,此处为:https://material.angular.io/components/tabs/api

enter image description here