加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – 如何使用材质2工具栏

发布时间:2020-12-17 17:27:35 所属栏目:安全 来源:网络整理
导读:我正在使用material2卡等,但在尝试添加工具栏时收到错误 app.component.html md-toolbar [color]="red" spanMy Application Title/span/md-toolbar app.module.ts import { BrowserModule } from '@angular/platform-browser';import { NgModule } from '@an
我正在使用material2卡等,但在尝试添加工具栏时收到错误

app.component.html

<md-toolbar [color]="red">
  <span>My Application Title</span>
</md-toolbar>

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import {OVERLAY_PROVIDERS} from "@angular2-material/core";

// Material 2 
import { MdCoreModule } from '@angular2-material/core'
import { MdButtonModule } from '@angular2-material/button';
import { MdCardModule } from '@angular2-material/card';
import { MdRadioModule } from '@angular2-material/radio';
import { MdCheckboxModule } from '@angular2-material/checkbox'
import { MdTooltipModule } from '@angular2-material/tooltip';
import { MdSliderModule } from '@angular2-material/slider';
import { MdToolbarModule,MdToolbarRow } from '@angular2-material/toolbar';


import 'hammerjs' ;

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

@NgModule({
  declarations: [
    AppComponent
  ],imports: [
    BrowserModule,FormsModule,HttpModule,MdCoreModule.forRoot(),MdCardModule.forRoot(),MdButtonModule.forRoot(),MdRadioModule.forRoot(),MdCheckboxModule.forRoot(),MdTooltipModule.forRoot(),MdSliderModule.forRoot(),MdToolbarModule.forRoot()
  ],providers: [OVERLAY_PROVIDERS],bootstrap: [AppComponent]
})
export class AppModule { }

我收到了错误

zone.js:388Unhandled Promise rejection: Template parse errors: Can’t
bind to ‘color’ since it isn’t a known property of ‘md-toolbar’.
1. If ‘md-toolbar’ is an Angular component and it has ‘color’ input,then verify that it is part of this module.
2. If ‘md-toolbar’ is a Web Component then add “CUSTOM_ELEMENTS_SCHEMA” to the ‘@NgModule.schema’ of this component
to suppress this message. (“

][color]=”red”> My Application
Title “): AppComponent@39:12 ‘md-toolbar’ is not a
known element:
1. If ‘md-toolbar’ is an Angular component,then verify that it is part of this module.
2. If ‘md-toolbar’ is a Web Component then add “CUSTOM_ELEMENTS_SCHEMA” to the ‘@NgModule.schema’ of this component
to suppress this message. (“

提前致谢

解决方法

现在它在app.compoent.ts更改后正在运行

import { MdToolbarModule,MdToolbarRow } from '@angular2-material/toolbar';

  imports: [
    MdToolbarModule.forRoot(),],

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读