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

} }

相关内容

热门资讯

透视黑科技!aapoker怎么... 透视黑科技!aapoker怎么提高中牌率(透视)插件(确实存在有挂)aapoker怎么提高中牌率软件...
透视讲解!aapoker辅助器... 透视讲解!aapoker辅助器怎么用(透视)免费透视脚本(都是真的是有挂);1、金币登录送、破产送、...
透视免费!aapoker公共底... 透视免费!aapoker公共底牌(透视)辅助(好像存在有挂)aapoker公共底牌软件透明挂微扑克w...
透视黑科技!aapoker能控... 透视黑科技!aapoker能控制牌吗(透视)插件下载(一直存在有挂);1、构建自己的aapoker能...
透视好友房!aapoker如何... 透视好友房!aapoker如何设置胜率(透视)透视脚本入口(果然真的是有挂)所有人都在同一条线上,像...
透视安装!aapoker透视插... 透视安装!aapoker透视插件(透视)透视脚本入口(真是真的是有挂);1、进入游戏-大厅左侧-新手...
透视最新!aa poker辅助... 透视最新!aa poker辅助(透视)透视脚本入口(竟然存在有挂);1、该软件可以轻松地帮助玩家将a...
透视游戏!aapoker透视怎... 透视游戏!aapoker透视怎么用(透视)脚本(原来是真的有挂)1)aapoker透视怎么用辅助挂:...
透视脚本!aa poker辅助... 透视脚本!aa poker辅助(透视)透视脚本下载(真是真的是有挂);1、首先打开aa poker辅...
透视计算!aapoker能控制... 透视计算!aapoker能控制牌吗(透视)辅助(真是是有挂);1、下载好aapoker能控制牌吗辅助...