AngularMaterial中的标签输入会抛出“chipInput不存在”的错误。
创始人
2024-10-28 11:35:26
0

可能是因为在HTML中,mat-chip-input需要在MatChipList中使用。可使用以下代码解决:

HTML代码:

{{fruit}} cancel

JavaScript代码:

import {Component, ViewChild, ElementRef} from '@angular/core'; import {MatChipInputEvent} from '@angular/material/chips'; import {COMMA, ENTER} from '@angular/cdk/keycodes';

@Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { fruits: string[] = ['Apple', 'Banana', 'Lemon']; separatorKeysCodes: number[] = [ENTER, COMMA];

add(event: MatChipInputEvent): void { const input = event.input; const value = event.value;

// Add our fruit
if ((value || '').trim()) {
  this.fruits.push(value.trim());
}

// Reset the input value
if (input) {
  input.value = '';
}

}

remove(fruit: string): void { const index = this.fruits.indexOf(fruit);

if (index >= 0) {
  this.fruits.splice(index, 1);
}

} }

相关内容

热门资讯

据相关数据显示!epoker底... 据相关数据显示!epoker底牌透视(透视)原来是有辅助神器(有挂详情)-哔哩哔哩小薇(辅助器软件下...
据玩家消息!hhpoker透视... 据玩家消息!hhpoker透视脚本下载(透视)切实有辅助插件(有挂神器)-哔哩哔哩1、上手简单,内置...
透视安装!拱趴大菠萝怎么开挂(... 透视安装!拱趴大菠萝怎么开挂(透视)切实真的有辅助软件(有挂细节)-哔哩哔哩1、用户打开应用后不用登...
目前来看!wepoker破解工... 目前来看!wepoker破解工具(透视)确实存在有辅助app(发现有挂)-哔哩哔哩该软件可以轻松地帮...
围绕透视问题!hhpoker辅... 围绕透视问题!hhpoker辅助器(透视)其实有辅助软件(有挂方法)-哔哩哔哩1、打开软件启动之后找...
透视黑科技!hhpoker有辅... 透视黑科技!hhpoker有辅助吗(透视)总是真的是有辅助平台(发现有挂)-哔哩哔哩1、很好的工具软...
于此同时!wepoker透视是... 于此同时!wepoker透视是真的吗(透视)确实存在有辅助app(有挂头条)-哔哩哔哩1、实时wep...
有消息称!wepoker插件功... 有消息称!wepoker插件功能辅助器(透视)一贯真的是有辅助修改器(确实有挂)-哔哩哔哩wepok...
透视有挂!悦扑克脚本(透视)竟... 透视有挂!悦扑克脚本(透视)竟然是真的辅助app(有挂分享)-哔哩哔哩1、完成悦扑克脚本有辅助插件,...
透视ai代打!wepoker辅... 透视ai代打!wepoker辅助器官方(透视)果然有辅助软件(有挂规律)-哔哩哔哩1、完成wepok...