![](/img/trans.png)
[英]Type “only refers to a type, but is being used as a value here” when exporting
[英]ng-multiselect-dropdown - 'IDropdownSettings' only refers to a type, but is being used as a value here
我正在尝试在我的 angular 应用程序中使用ng-multiselect-dropdown
。
我在定义设置时收到此错误是 VSCode:
'IDropdownSettings' 仅指一种类型,但在此处用作值.ts(2693)
我已经使用npm i ng-multiselect-dropdown
导入了模块,并且我在app.module.ts
中定义了。 我在这里按照指南进行操作。
我的设置在我的page.component.ts
中是这样的:
import { IDropdownSettings } from 'ng-multiselect-dropdown'
export class VQCComponent implements OnInit {
dropdownSettings = {};
ngOnInit() {
this.dropdownSettings:IDropdownSettings = {
singleSelection: false,
idField: 'item_id',
textField: 'item_text',
selectAllText: 'Select All',
unSelectAllText: 'Unselect All',
itemsShowLimit: 3,
allowSeachFilter: true
}
}
}
此行突出显示错误:
this.dropdownSettings:IDropdownSettings = {
是什么导致了这个错误? 我已按照指南进行操作,但似乎在此模块上找不到任何其他文档。
只能在声明时键入变量:
export class VQCComponent implements OnInit {
dropdownSettings:IDropdownSettings;
ngOnInit() {
this.dropdownSettings = {
singleSelection: false,
idField: 'item_id',
textField: 'item_text',
selectAllText: 'Select All',
unSelectAllText: 'Unselect All',
itemsShowLimit: 3,
allowSeachFilter: true
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.