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插件,wepoker好友房开挂,学习教程(新版有挂)-哔哩哔哩1、全新机制【...
详细透视!哈糖大菠萝怎么挂!都... 详细透视!哈糖大菠萝怎么挂!都是有辅助插件(存在有挂)-哔哩哔哩一、哈糖大菠萝怎么挂游戏安装教程牌型...
曝光透视!约局吧德州可以透视吗... 曝光透视!约局吧德州可以透视吗,wepoker辅助器最新版本更新内容,举措教程(存在有挂)-哔哩哔哩...
解谜透视!拱趴大菠萝挂哪里!确... 解谜透视!拱趴大菠萝挂哪里!确实是真的有辅助工具(有挂技术)-哔哩哔哩1、下载好拱趴大菠萝挂哪里正确...
有挂透视!we poker辅助... 有挂透视!we poker辅助器,wepoker免费脚本咨询,模板教程(确实有挂)-哔哩哔哩wepo...
科普透视!pokermaste... 科普透视!pokermaster脚本!确实真的是有辅助教程(存在有挂)-哔哩哔哩运pokermast...
了解透视!hhpoker德州作... 了解透视!hhpoker德州作必弊,hhpoker透视脚本视频,机巧教程(有挂攻略)-哔哩哔哩hhp...
解迷透视!impoker辅助!... 解迷透视!impoker辅助!其实真的有辅助app(证实有挂)-哔哩哔哩一、impoker辅助游戏安...
有挂透视!wepoker私人局... 有挂透视!wepoker私人局俱乐部,we poker免费辅助器,阶段教程(有挂分享)-哔哩哔哩1....
分享透视!智星菠萝透视!真是是... 分享透视!智星菠萝透视!真是是有辅助教程(有挂细节)-哔哩哔哩智星菠萝透视辅助器是一种具有地方特色的...