所以我在使用角度6时遇到了一些困难。我会尽力解释:
我正在研究一个根据MIT许可获得许可的项目,它已经是一个非常可靠的基础项目。现在,我已经按照所需的方式对其进行了样式设置,我想生成一个新的组件,可以将其制作为用户可以填写的表单。
因此,我打开CLI和ng g c FeeSchedule
,可以看到fee-schedule
组件已制成。我认为在这一点上,我应该可以编译并查看正在运行的<p> "fee-schedule works!" message <p>
(如果包含的话)。
生成组件后生成时出错:似乎是TS-Lint故障?
`System.InvalidOperationException:NPM脚本“ serve”已退出 而不表示Angular CLI正在侦听请求。 错误输出为:在列出的文件中发现Lint错误。
npm错误!代码ELIFECYCLE
npm错误! errno 1
npm错误! project@1.0.0服务:
ng lint && ng serve "--port" "6685"
npm ERR!退出状态1 npm ERR! npm ERR!在project@1.0.0上失败 服务脚本。 npm ERR! npm可能不是问题。那里 可能是上面的其他日志记录输出。npm错误!可以在以下位置找到此运行的完整日志:
---> System.IO.EndOfStreamException:尝试读取末尾的内容 流。在 Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.StartAngularCliServerAsync(String sourcePath,字符串npmScriptName,ILogger记录器)---内部结尾 异常堆栈跟踪--- Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.StartAngularCliServerAsync(String sourcePath,字符串npmScriptName,ILogger记录器)`
有人知道为什么在生成新组件时会遇到问题吗?
我将尽可能包含尽可能多的相关代码:
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { RouterModule } from "@angular/router";
import { AppComponent } from "./app.component";
import { ROUTES } from "./app.routes";
import { LayoutModule } from "./views/layout/layout.module";
import { FeeScheduleComponent } from './views/fee-schedule/fee-schedule.component';
@NgModule({
bootstrap: [AppComponent],
declarations: [AppComponent, FeeScheduleComponent],
imports: [
BrowserModule,
RouterModule.forRoot(ROUTES),
LayoutModule
]
})
export class AppModule { }
和我的股票费用计划部分:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-fee-schedule',
templateUrl: './fee-schedule.component.html',
styleUrls: ['./fee-schedule.component.css']
})
export class FeeScheduleComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
我认为必须提及的一点是,即使我删除了index.html中的app-fee-schedule调用,该应用程序仍然无法运行。
随附了我的ts lint配置;
{
"extends": [ "tslint:latest" ],
"rulesDirectory": [ "node_modules/codelyzer" ],
"rules": {
"angular-whitespace": [ true, "check-interpolation", "check-pipe", "check-semicolon" ],
"banana-in-box": true,
"component-class-suffix": [ true, "Component" ],
"component-selector": [ true, "element", "app", "kebab-case" ],
"contextual-life-cycle": true,
"decorator-not-allowed": true,
"directive-class-suffix": [ true, "Directive" ],
"directive-selector": [ true, "attribute", "app", "camelCase" ],
"import-destructuring-spacing": true,
"indent": [ true, "tabs", 4 ],
"max-line-length": false,
"member-access": [ true, "no-public" ],
"no-attribute-parameter-decorator": true,
"no-console": false,
"no-empty": false,
"no-forward-ref": true,
"no-input-rename": true,
"no-output-named-after-standard-event": true,
"no-output-on-prefix": true,
"no-output-rename": true,
"no-submodule-imports": false,
"no-unused-css": true,
"no-var-requires": false,
"pipe-impure": true,
"pipe-naming": [ "camelCase", "Pipe" ],
"templates-no-negated-async": true,
"trailing-comma": false,
"use-host-property-decorator": true,
"use-input-property-decorator": true,
"use-life-cycle-interface": true,
"use-output-property-decorator": true,
"use-pipe-decorator": true,
"use-pipe-transform-interface": true,
"use-view-encapsulation": true
}
}