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

} }

相关内容

热门资讯

解迷透视!wpk透视怎么安装,... 解迷透视!wpk透视怎么安装,微乐自建房辅助工具在哪,教材教程(有挂教程)-哔哩哔哩1、完成wpk透...
普及透视!aapoker公共底... 普及透视!aapoker公共底牌,微乐南昌辅助神器,烘培教程(详细教程)-哔哩哔哩暗藏猫腻,小编详细...
详细透视!佛手在线有挂吗,微信... 详细透视!佛手在线有挂吗,微信小程序可以开挂吗,学习教程(有挂技术)-哔哩哔哩佛手在线有挂吗辅助器是...
辅助透视!hhpoker是内部... 辅助透视!hhpoker是内部控制吗,微乐贵阳捉鸡麻将挂软件,办法教程(有挂方式)-哔哩哔哩1、玩家...
解谜透视!wejoker内置辅... 解谜透视!wejoker内置辅助,微乐自建房怎么提高运气,法子教程(有挂透明挂)-哔哩哔哩1、wej...
解迷透视!wepoker作弊方... 解迷透视!wepoker作弊方法,微乐a3纸牌有脚本,大纲教程(真的有挂)-哔哩哔哩1)wepoke...
辅助透视!wpk透视是真的假的... 辅助透视!wpk透视是真的假的,微乐自建房脚本最新版本更新内容,步骤教程(有挂秘籍)-哔哩哔哩暗藏猫...
专业透视!智星菠萝有挂吗,微乐... 专业透视!智星菠萝有挂吗,微乐自建房脚本下载,模块教程(了解有挂)-哔哩哔哩1、下载好智星菠萝有挂吗...
有挂透视!aapoker透视怎... 有挂透视!aapoker透视怎么用,微乐自建房运势高有什么表现,机巧教程(有挂技术)-哔哩哔哩1、a...
解密透视!德普之星透视辅助,小... 解密透视!德普之星透视辅助,小程序微乐陕西挖坑辅助器,方式教程(有挂透明挂)-哔哩哔哩1、打开软件启...