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

} }

相关内容

热门资讯

透视挂"wepoke... 透视挂"wepoker私人局俱乐部辅助"werplan外卦神器(一直是有辅助安装)-哔哩哔哩1、操作...
针对"pokemmo... 针对"pokemmo脚本辅助"wepoker钻石怎么看底牌(竟然有辅助插件)-哔哩哔哩1、超多福利:...
透视辅助"wepok... 透视辅助"wepoker透视挂底牌"wepoker透视最简单三个步骤(其实有辅助app)-哔哩哔哩1...
连日来"哈糖大菠萝可... 连日来"哈糖大菠萝可以开挂吗"德州透视是真的假的(一贯是有辅助平台)-哔哩哔哩哈糖大菠萝可以开挂吗透...
推出新举措"wepo... 推出新举措"wepoker国外版透视"wpk透视怎么安装(其实是有辅助app)-哔哩哔哩1、wepo...
有玩家发现"hhpo... 有玩家发现"hhpoker辅助软件是真的么"wepoker辅助分析器(一贯存在有辅助神器)-哔哩哔哩...
今天下午"wepok... 今天下午"wepoker破解器"wepoker开辅助能查到吗(切实真的是有辅助工具)-哔哩哔哩一、w...
近日"hhpoker... 近日"hhpoker辅助器"德普之星怎么设置埋牌(总是真的有辅助神器)-哔哩哔哩1、完成德普之星怎么...
最终"wepoker... 最终"wepoker怎么开辅助"pokemmo内置修改器(竟然是有辅助软件)-哔哩哔哩1、进入游戏-...
透视辅助"wepok... 透视辅助"wepoker软件安装包"wepoker免费脚本咨询(本来存在有辅助辅助器)-哔哩哔哩一、...