类型“string[]"上不存在属性“includes" [英] Property 'includes' does not exist on type 'string[]'
问题描述
出现错误
'string[]' 类型不存在属性 'includes'
Property 'includes' does not exist on type 'string[]'
在 node_modules/ng2-breadcrumb/app/components/breadcrumbService.ts我正在尝试在 angular2 应用中实现面包屑功能.
in node_modules/ng2-breadcrumb/app/components/breadcrumbService.ts I am trying to implement breadcrumb functionality in an angular2 app.
推荐答案
将 "ES2017"
添加到 tsconfig.json 中的
代码>:"lib"
数组
Add "ES2017"
to your "lib"
array in tsconfig.json
:
{
"compilerOptions": {
...
"lib": ["es6", "dom", "es2017"],
...
"target": "es5",
...
}
}
这应该从 TypeScript 2.1 开始工作.
This should work since TypeScript 2.1.
一个相关问题.
includes<从 ES7 (ES2016) 开始支持
方法.以上将添加一个缺少的库文件进行编译.Array
上的/code>
The includes
method on Array
is supported since ES7 (ES2016). The above will add a missing library file to compilation.
TypeScript 编译器选项记录在此处.
The TypeScript compiler options are documented here.
Lib es2016
或 es7
可能足以代替 es2017
(未测试).
Lib es2016
or es7
may be sufficient instead of es2017
(not tested).
这篇关于类型“string[]"上不存在属性“includes"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!