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);
}

} }

相关内容

热门资讯

透视推荐"fishp... 透视推荐"fishpoker透视"一贯有辅助脚本(哔哩哔哩)1、fishpoker透视有没有辅助教程...
透视教你"aapok... 透视教你"aapoker真的假的"本来真的有辅助方法(哔哩哔哩)1、打开软件启动之后找到中间准星的标...
透视解密"约局吧德州... 透视解密"约局吧德州透视"一直有辅助技巧(哔哩哔哩)1)约局吧德州透视有没有挂:进一步探索约局吧德州...
透视关于"sohoo... 透视关于"sohoo开挂辅助"好像是有辅助插件(哔哩哔哩);1、该软件可以轻松地帮助玩家将sohoo...
透视解密"pokem... 透视解密"pokemmo脚本辅助器"果然存在有辅助器(哔哩哔哩)透视解密"pokemmo脚本辅助器"...
透视辅助"hh po... 透视辅助"hh poker插件下载"真是是有辅助神器(哔哩哔哩)1、实时hh poker插件下载透视...
透视开挂"poker... 透视开挂"poker辅助器免费安装"其实真的有辅助神器(哔哩哔哩)1、poker辅助器免费安装模拟器...
透视了解"wepok... 透视了解"wepoker透视脚本"一贯真的有辅助脚本(哔哩哔哩)1、玩家可以在wepoker透视脚本...
透视推荐"wepok... 透视推荐"wepoker私人局开挂视频"一贯存在有辅助神器(哔哩哔哩)1、进入游戏-大厅左侧-新手福...
透视普及"来玩德州破... 透视普及"来玩德州破解器"本来真的是有辅助攻略(哔哩哔哩)1、来玩德州破解器辅助器安装包、来玩德州破...