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透视(H... 透视窍要!epoker透视(HHpoker功能)果然是有辅助方法(哔哩哔哩)1、每一步都需要思考,不...
透视技法!wepoker轻量版... 透视技法!wepoker轻量版透视方法(WePoKer祈福)总是真的是有辅助软件(哔哩哔哩)1、在w...
透视秘籍!wepoker免费脚... 透视秘籍!wepoker免费脚本咨询(德普之星有透视)真是有辅助教程(哔哩哔哩)1、许多玩家不知道w...
透视教材!werplan脚本(... 透视教材!werplan脚本(德普之星下载)切实是真的有辅助神器(哔哩哔哩)1、游戏颠覆性的策略玩法...
透视策略!xpoker辅助器(... 透视策略!xpoker辅助器(WePoKer透视脚本)一贯存在有辅助方法(哔哩哔哩)1、玩家可以在x...
透视方针!hhpoker德州作... 透视方针!hhpoker德州作必弊(WePoKer咨询)一贯真的有辅助教程(哔哩哔哩)透视方针!hh...
透视烘培!hhpoker透视脚... 透视烘培!hhpoker透视脚本视频(德普之星辅助软件)确实有辅助方法(哔哩哔哩)1、很好的工具软件...
透视积累!hhpoker德州透... 透视积累!hhpoker德州透视(德普之星开辅助)真是是真的有辅助技巧(哔哩哔哩)1、打开软件启动之...
透视法门!wepoker透视脚... 透视法门!wepoker透视脚本苹果版(AApoker安装包)确实有辅助技巧(哔哩哔哩)wepoke...
透视策略!聚星ai辅助工具下载... 透视策略!聚星ai辅助工具下载(WePoKer私人)都是是真的有辅助app(哔哩哔哩)聚星ai辅助工...