【发布时间】:2019-08-05 08:30:16
【问题描述】:
我在 Angular 7 项目中遇到以下错误。我已经使用 npm 安装了 typescript,这可能意味着最新的 typescript 版本。
错误 TS2339:“主题”类型上不存在属性“startWith”。
app.component.ts
this.language
.startWith(this.translationService.getBrowserLang())
.subscribe(lang => this.store.dispatch(new LanguageAction(lang)))
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}
【问题讨论】:
-
您正在尝试使用字符串的实用程序通过w3schools.com/jsref/jsref_startswith.asp 我想您必须在使用
pipe时进行逻辑 -
@Bibin 能否请您添加您如何声明/初始化或注入
this.language的代码?
标签: angular