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怎么开辅助,wpk插件,专业教程(有挂透视);人气非常高,ai更新快且高清可...
透视好友!德州真人透视脚本(透... 透视好友!德州真人透视脚本(透视)一直真的是有挂(详细辅助技巧教程)一、AI软件牌型概率发牌机制”必...
玩家必备攻略!wepoker免... 玩家必备攻略!wepoker免费透视脚本,pokemmo辅助官网,科技教程(有挂辅助)1、点击下载安...
信息共享!we poker插件... 信息共享!we poker插件,we-poker辅助,线上教程(有挂辅助)1、点击下载安装,微扑克w...
带你了解!hhpoker德州有... 1、带你了解!hhpoker德州有挂吗,werplan外挂,科技教程(有挂攻略)2、进入游戏-大厅左...
一分钟了解!wejoker辅助... 一分钟了解!wejoker辅助脚本,微扑克微乐辅助,wepoke教程(有挂技巧);《WPK辅助透视》...
今日重大通报!wejoker私... 今日重大通报!wejoker私人辅助软件,智星德州可以透视吗,高科技教程(有挂透明);玩家必备必赢加...
必备科技!wepoker有用吗... 必备科技!wepoker有用吗,wepoker私人局辅助挂,2025教程(有挂方法);最新版2024...
玩家攻略!wejoker辅助软... 玩家攻略!wejoker辅助软件价格,wejoker内置辅助,解密教程(有挂神器)1、玩家可以在we...
玩家必看科普!pokemmo辅... 玩家必看科普!pokemmo辅助器脚本下载,wepoker透视脚本是什么,德州教程(有挂方法);po...