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

} }

相关内容

热门资讯

外挂办法!大菠萝免费辅助器,p... 外挂办法!大菠萝免费辅助器,pokerrrr2辅助-切实是有辅助插件(哔哩哔哩)1、进入到大菠萝免费...
外挂讲义!拱趴游戏破解器,we... 外挂讲义!拱趴游戏破解器,werplan免费挂下载-总是是真的有辅助工具(哔哩哔哩)小薇(辅助器软件...
外挂妙招!线上德州的辅助器是什... 外挂妙招!线上德州的辅助器是什么,德州透视插件-都是有辅助插件(哔哩哔哩)1)线上德州的辅助器是什么...
外挂阶段!德州真人透视脚本,佛... 外挂阶段!德州真人透视脚本,佛手大菠萝13道挂哪里-本来真的是有辅助app(哔哩哔哩)1)佛手大菠萝...
外挂积累!德州圈脚本,拱趴大菠... 外挂积累!德州圈脚本,拱趴大菠萝有什么挂-都是是有辅助攻略(哔哩哔哩)1、点击下载安装,拱趴大菠萝有...
外挂教材!哈糖大菠萝有挂吗5个... 外挂教材!哈糖大菠萝有挂吗5个常用方法,德普辅助软件-好像真的是有辅助软件(哔哩哔哩)1)哈糖大菠萝...
外挂指南书!pokernow辅... 外挂指南书!pokernow辅助控制,德普之星辅助器怎么用-竟然有辅助插件(哔哩哔哩)pokerno...
外挂要领!德普之星辅助器,约局... 外挂要领!德普之星辅助器,约局吧德州可以透视吗-其实有辅助神器(哔哩哔哩)暗藏猫腻,小编详细说明约局...
外挂步骤!德普之星透视辅助软件... 外挂步骤!德普之星透视辅助软件下载,werplan脚本-都是真的有辅助技巧(哔哩哔哩)1、超多福利:...
外挂讲义!uupoker有透视... 外挂讲义!uupoker有透视吗,德普之星app安卓版破解版-其实是有辅助方法(哔哩哔哩);暗藏猫腻...