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

} }

相关内容

热门资讯

透视指南!pokerworld... 透视指南!pokerworld破解版下载(透视)佛手大菠萝13道挂哪里(辅助)竟然真的是有app(哔...
透视课程!pokemmo脚本辅... 透视课程!pokemmo脚本辅助器下载(透视)德州透视插件(辅助)真是是真的有攻略(哔哩哔哩)进入游...
透视总结!sohoo辅助(透视... 透视总结!sohoo辅助(透视)拱趴大菠萝开挂方法(辅助)一直真的是有攻略(哔哩哔哩)1、全新机制【...
透视大纲!hhpoker万能辅... 透视大纲!hhpoker万能辅助器(WePoKer新版本)总是真的是有辅助软件(哔哩哔哩)1、完成h...
透视阶段!pokemmo脚本(... 透视阶段!pokemmo脚本(透视)来玩app 德州 辅助(辅助)原来是有神器(哔哩哔哩)一、来玩a...
透视指南书!wepoker辅助... 透视指南书!wepoker辅助器激活码(HHpoker控制牌)都是存在有辅助脚本(哔哩哔哩)进入游戏...
透视技法!wepoker透视功... 透视技法!wepoker透视功能下载(HHpoker辅助)其实真的是有辅助教程(哔哩哔哩)1、很好的...
透视举措!wepoker轻量版... 透视举措!wepoker轻量版有透视吗(WePoKer最新)原来是真的有辅助app(哔哩哔哩)1、全...
透视模板!pokemmo脚本(... 透视模板!pokemmo脚本(透视)德州真人透视脚本(辅助)真是是有技巧(哔哩哔哩)亲,关键说明,德...
透视妙计!云扑克有透视吗(透视... 您好,pokemmo脚本辅助下载这款游戏可以开挂的,确实是有挂的,需要了解加去威信【13670430...