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

} }

相关内容

热门资讯

外挂绝活!来玩app破解版,哈... 外挂绝活!来玩app破解版,哈糖大菠萝破解器-真是有辅助神器(哔哩哔哩)1、哈糖大菠萝破解器免费辅助...
外挂学习!来玩app破解,we... 外挂学习!来玩app破解,werplan有挂吗-都是有辅助工具(哔哩哔哩)1、werplan有挂吗辅...
外挂办法!如何下载德普之星辅助... 外挂办法!如何下载德普之星辅助软件,德普之星辅助软件-好像真的是有辅助工具(哔哩哔哩)辅助器是一种具...
外挂总结!werplan免费挂... 外挂总结!werplan免费挂下载,xpoker怎么作必弊-确实存在有辅助app(哔哩哔哩)1、we...
外挂攻略!pokerworld... 您好,拱趴大菠萝怎么开挂这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多...
外挂阶段!云扑克有透视吗,德普... 外挂阶段!云扑克有透视吗,德普辅助器怎么用-好像一直都是有辅助教程(哔哩哔哩)1、游戏颠覆性的策略玩...
外挂方式!聚星ai辅助工具激活... 外挂方式!聚星ai辅助工具激活码,德普之星透视辅助软件-总是真的有辅助教程(哔哩哔哩)1、下载好聚星...
外挂模板!德州透视插件,拱趴大... 外挂模板!德州透视插件,拱趴大菠萝有什么挂-总是一直总是有辅助工具(哔哩哔哩)拱趴大菠萝有什么挂脚本...
外挂模块!哈糖大菠萝怎么挂,p... 外挂模块!哈糖大菠萝怎么挂,poker master辅助-总是真的有辅助教程(哔哩哔哩)1、下载好哈...
外挂举措!来玩app破解,竞技... 外挂举措!来玩app破解,竞技联盟破解版最新版-总是存在有辅助方法(哔哩哔哩)在进入竞技联盟破解版最...