问题描述
我以前在Angular 6中使用console.log来查看浏览器中变量的内容
I used to have my console.log in Angular 6 to see the content of variables in the browser
console.log('CONSOLOG: M:paginateVar & O: this.var : ', this.var);
...,我对此感到满意,但是现在我开始使用Angular 8,并且出现此错误(当我启动npm时):
... and I was happy with it, but now I'm starting to use Angular 8 and I get this error (when I npm start):
No type errors found
Version: typescript 3.4.5
Time: 2104ms
× 「wdm」: 1029 modules
ERROR in ./src/main/webapp/app/home/home.component.ts
Module Error (from ./node_modules/eslint-loader/dist/cjs.js):
D:\JHipster\spingular\src\main\webapp\app\home\home.component.ts
105:7 error Unexpected console statement no-console
✖ 1 problem (1 error, 0 warnings)
i 「wdm」: Failed to compile.
如何在浏览器中查看变量的内容?
How can I see the content of a variable back in the browser?
TSLINT:
{
"rulesDirectory": ["node_modules/codelyzer"],
"rules": {
"no-console": [false, "debug", "info", "time", "timeEnd", "trace" ],
"directive-selector": [true, "attribute", "jhi", "camelCase"],
"component-selector": [true, "element", "jhi", "kebab-case"],
"no-inputs-metadata-property": true,
"no-outputs-metadata-property": true,
"no-host-metadata-property": true,
"no-input-rename": true,
"no-output-rename": true,
"use-lifecycle-interface": true,
"use-pipe-transform-interface": false,
"component-class-suffix": true,
"directive-class-suffix": true
}
}
感谢您的帮助
推荐答案
这是Node.js中的ESLint规则.
This is an ESLint rule in Node.js.
https://eslint.org/docs/rules/no-console
被禁用的原因:
您可能希望考虑使用记录器: https://github.com/code-chunks/angular2-logger
You may like to consider a logger: https://github.com/code-chunks/angular2-logger
但是,如果您确实只想允许console.log,则可以编辑设置的规则:
However, if you really just want to allow console.log you can edit the rules to set:
这篇关于如何在Angular 8中使用console.log?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!