嘗試在我的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 –