Arrays Angular 2:Array.find不是函数
调用此函数时,它返回以下错误:this.selected.find不是函数 我怎样才能解决这个问题 编辑: typescript版本是2.0.10 tsconfig文件:Arrays Angular 2:Array.find不是函数,arrays,angular,typescript,Arrays,Angular,Typescript,调用此函数时,它返回以下错误:this.selected.find不是函数 我怎样才能解决这个问题 编辑: typescript版本是2.0.10 tsconfig文件: select(object: Mill | Paver | Vehicle) { if (!this.selected.find(o => o.object === object)) { if (object instanceof Paver || object instanceof Vehicl
select(object: Mill | Paver | Vehicle) {
if (!this.selected.find(o => o.object === object)) {
if (object instanceof Paver || object instanceof Vehicle) {
this.selected.push(this.getTripsFromPlanning(object));
} else {
this.selected.push({
object: object,
marker: this.mapService.addMarker(object.location, object.name, false, 0)
});
};
}
}
显然,
此。选定的
不是数组。您是否尝试过console.log(this.selected)
以了解this.selected
实际上是什么?在angular 2中,您必须使用Array.filter而不是Array.find.what?您也可以在angular2中使用Array.find。为什么这应该与angular2控制台相关。log(this.selected)不会返回任何明显的信息。selected
不是数组。您是否尝试过console.log(this.selected)
以了解this.selected
实际上是什么?在angular 2中,您必须使用Array.filter而不是Array.find.what?您也可以在angular2中使用Array.find。为什么这应该与angular2控制台相关。log(this.selected)不返回任何内容
select(object: Mill | Paver | Vehicle) {
if (!this.selected.find(o => o.object === object)) {
if (object instanceof Paver || object instanceof Vehicle) {
this.selected.push(this.getTripsFromPlanning(object));
} else {
this.selected.push({
object: object,
marker: this.mapService.addMarker(object.location, object.name, false, 0)
});
};
}
}
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"suppressImplicitAnyIndexErrors": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es6",
"typeRoots": [
"../node_modules/@types"
]
}
}