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、这是跨平台的w...
透视苹果版!pokemomo辅... 透视苹果版!pokemomo辅助软件(透视)一贯是真的辅助修改器(的确有挂)-哔哩哔哩1、玩家可以在...
随着!约局吧德州真的有透视挂吗... 随着!约局吧德州真的有透视挂吗(透视)一直是有辅助平台(有挂详情)-哔哩哔哩1、打开软件启动之后找到...
经核实!约局吧德州真的存在透视... 经核实!约局吧德州真的存在透视吗(透视)都是有辅助app(有挂方法)-哔哩哔哩1)约局吧德州真的存在...
昨日!steampokerma... 昨日!steampokermaster辅助(透视)本来是真的辅助安装(有挂分析)-哔哩哔哩1、超多福...
透视攻略!wepoker究竟有... 透视攻略!wepoker究竟有没有透视(透视)切实真的有辅助插件(有挂详细)-哔哩哔哩1、该软件可以...
有了最新消息!hhpoker有... 有了最新消息!hhpoker有没有外开挂(透视)确实真的有辅助软件(有挂总结)-哔哩哔哩1、完成hh...
此事引发广泛关注!大菠萝789... 您好,大菠萝789辅助器下载这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】...
透视黑科技!wpk俱乐部是做什... 透视黑科技!wpk俱乐部是做什么的(透视)原来是真的辅助app(有挂分析)-哔哩哔哩暗藏猫腻,小编详...
为了进一步!wejoker开挂... 为了进一步!wejoker开挂(透视)其实是真的辅助修改器(有挂秘籍)-哔哩哔哩;1、wejoker...