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

} }

相关内容

热门资讯

透视真的!wepoker底牌透... 透视真的!wepoker底牌透视(透视)牵手游戏辅助(果然是真的辅助神器)-哔哩哔哩1、超多福利:超...
为切实保障!werplan免费... 您好,心悦手游辅助器这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很多玩家...
透视脚本!wejoker透视方... 透视脚本!wejoker透视方法(透视)新全游辅助器(一贯是有辅助平台)-哔哩哔哩1、完成新全游辅助...
目前!pokemmo免费脚本(... 目前!pokemmo免费脚本(透视)至臻辅助(真是是有辅助下载)-哔哩哔哩1、每一步都需要思考,不同...
连日来!wepoker透视ap... 连日来!wepoker透视app下载(透视)湖南牵手胡子跑脚本(都是真的有辅助工具)-哔哩哔哩1、连...
经核实!hhpoker免费透视... 经核实!hhpoker免费透视脚本(透视)小程序能开挂吗(总是存在有辅助修改器)-哔哩哔哩1、该软件...
透视脚本!hardrock透视... 透视脚本!hardrock透视工具(透视)广东雀神智能插件安装辅助器(一贯是真的辅助下载)-哔哩哔哩...
透视辅助!aapoker辅助器... 透视辅助!aapoker辅助器是真的吗(透视)腾威互娱辅助工具(其实真的是有辅助下载)-哔哩哔哩腾威...
有玩家发现!约局吧开挂(透视)... 有玩家发现!约局吧开挂(透视)江湖悠悠手游辅助工具(总是有辅助安装)-哔哩哔哩1、进入游戏-大厅左侧...
透视了解!德州局怎么透视(透视... 透视了解!德州局怎么透视(透视)有没有哈糖大菠萝攻略推荐(都是是有辅助安装)-哔哩哔哩1、进入到有没...