尝试在我的component.ts文件中使用.includes,但它会引发以下错误。帮助我解决问题。.includes在类型'string []'上不存在
- 错误
属性 '包括' 不上型存在 '串[]'
app.component.ts
permissionCookie: string[]; this.permissionCookie = cookieService.get("permissions").split(","); this.permissionFlag = this.permissionCookie.includes("22");
ts.config
{ "compilerOptions": { "baseUrl": "", "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": ["es6", "dom"], "mapRoot": "./", "module": "es6", "moduleResolution": "node", "outDir": "../dist/out-tsc", "sourceMap": true, "target": "es5", "typeRoots": [ "../node_modules/@types" ] } }
这Property 'includes' does not exist on type 'string[]'没有帮助我要么
this.permissionCookie - 这是一个数组吗?包含仅适用于数组。 – RemyaJ
你说你发布的链接中的解决方案没有工作,但你的配置根本不使用它。它说为目标使用'es2016',而你不是。 'includes'是ES2016的一部分时,其他所有内容都设置为ES6。 – GillesC
是的,这是... @ RemyaJ –