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

} }

相关内容

热门资讯

透视真的!红龙poker辅助,... 透视真的!红龙poker辅助,wepoker私局辅助(透视)总结教程(有挂方式)-哔哩哔哩1、金币登...
在玩家背景下!wpk插件辅助,... 在玩家背景下!wpk插件辅助,哈糖大菠萝免费辅助器(透视)了解教程(今日头条)-哔哩哔哩1)哈糖大菠...
透视模拟器!拱趴大菠萝挂哪里,... 透视模拟器!拱趴大菠萝挂哪里,wepokerplus辅助(透视)详细教程(有挂方式)-哔哩哔哩透视模...
于此同时!拱趴大菠萝自动计算机... 于此同时!拱趴大菠萝自动计算机器人,wepoker透视脚本免费(透视)科普教程(真的有挂)-哔哩哔哩...
辅助透视!德州来玩辅助器,we... 辅助透视!德州来玩辅助器,wepoker透视辅助下载(透视)普及教程(有挂规律)-哔哩哔哩1.wep...
透视科技!德州hhpoker脚... 透视科技!德州hhpoker脚本,wepoker怎么开辅助(透视)科普教程(有挂教学)-哔哩哔哩1)...
相较于以往!聚星ai辅助工具激... 相较于以往!聚星ai辅助工具激活码,模拟器打开hhpoker(透视)了解教程(的确有挂)-哔哩哔哩1...
透视计算!wepoker底牌透... 透视计算!wepoker底牌透视,佛手在线是不是有挂(透视)详细教程(有挂解惑)-哔哩哔哩佛手在线是...
透视透视!wepoker-h5... 透视透视!wepoker-h5下载,约局吧德州可以透视吗(透视)必备教程(有挂教学)-哔哩哔哩透视透...
透视app!wpk模拟器多开,... 透视app!wpk模拟器多开,hardrock透视工具(透视)解密教程(有挂秘诀)-哔哩哔哩1、全新...