当我使用Angular CLI(8.0.0)生成项目时,运行ng serve
,在Internet Explorer中打开应用程序,然后出现空白屏幕。
我看了看polyfills.ts
文件,并取消了以下几行的注释:
import 'classlist.js';
import 'web-animations-js';
Run Code Online (Sandbox Code Playgroud)
我也删除了所有core.js导入,因为Angular 8直接支持core.js 3.0。
我也跑了npm i
。
package.json:
"dependencies": {
"@angular/animations": "~8.0.0",
"@angular/common": "~8.0.0",
"@angular/compiler": "~8.0.0",
"@angular/core": "~8.0.0",
"@angular/forms": "~8.0.0",
"@angular/platform-browser": "~8.0.0",
"@angular/platform-browser-dynamic": "~8.0.0",
"@angular/router": "~8.0.0",
"classlist.js": "^1.1.20150312",
"rxjs": "~6.4.0",
"tslib": "^1.9.0",
"web-animations-js": "^2.3.1",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.800.0",
"@angular/cli": "~8.0.0",
"@angular/compiler-cli": "~8.0.0",
"@angular/language-service": "~8.0.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1", …
Run Code Online (Sandbox Code Playgroud) 我有一个 Angular 8 项目,我运行ng lint
.
即使我有一个@description
与特定方法相关联的装饰器,TSLint 也会抱怨并说:"'@param' is redundant in TypeScript code if it has no description."
在我的代码中的不同地方。
例如,上述错误会显示当一个方法是这样编写的(TypeScript):
/**
* @description my lovely description
* @param empDetails
*/
getHeaderBasedonEmpDetails(empDetails: EmployeeDetails) {
if (someVar) {
return 'yeah'
} else {
return 'nah'
}
}
Run Code Online (Sandbox Code Playgroud)
包.json:
{
"name": "example-app",
"version": "0.0.0",
"private": true,
"dependencies": {
"@angular/animations": "^8.0.0",
"@angular/cdk": "^8.0.0",
"@angular/common": "^8.0.0",
"@angular/compiler": "^8.0.0",
"@angular/core": "^8.0.0",
"@angular/flex-layout": "^8.0.0-beta.26",
"@angular/forms": "^8.0.0",
"@angular/http": "^7.2.15",
"@angular/language-service": "^8.0.0",
"@angular/material": "^6.3.3",
"@angular/material-moment-adapter": …
Run Code Online (Sandbox Code Playgroud) single-page-application typescript ecmascript-6 angular angular8
我有一个函数可以将 HTMLaria-expanded
属性动态更新为 true 或 false。但是,当我输入element
as 时HTMLElement
,我收到一个Argument of type 'boolean' is not assignable to parameter of type 'string'
expandEotyDocumentsPanel(element: HTMLElement) {
this.eotyExpanded = !this.eotyExpanded;
element.setAttribute('aria-expanded', this.eotyExpanded);
}
Run Code Online (Sandbox Code Playgroud)
您可能已经注意到,this.eotyExpanded
是一个布尔值。
关于 的第二个参数setAttribute()
,MDN上的文档说:
包含要分配给属性的值的 DOMString。任何指定的非字符串值都会自动转换为字符串。
所以我认为提供一个布尔值就可以了。
我怎样才能抑制这个错误?
谢谢。
我有一个网站。让我们称之为www.example.com
。
我加载了一个 iframe,www.example.com
其中是一个 PWA。
是否可以在 iframe 中安装 PWA?如果不是,为什么?
我是 Jest 的新手,我想开始为 Node.js 服务器编写一些集成测试。当我尝试运行测试时,我收到一个"TypeError: wsModule.Server is not a constructor"
错误。为什么我的测试环境不会初始化套接字服务器?
服务器.js:
const app = require('express')();
const server = require('http').Server(app);
const io = require('socket.io')(server); <-- TEST FAILS BECAUSE OF SOCKET MODULE
const router = require('./router/router');
const bodyParser = require('body-parser');
const cors = require('cors');
require('./socket/socket')(io);
// Allow CORS so our client can consume JSON
app.use(cors())
// Takes the raw requests and turns them into usable properties on req.body
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// Use our router
app.use('/', router);
server.listen(3000, …
Run Code Online (Sandbox Code Playgroud) angular ×3
angular8 ×2
typescript ×2
angular-cli ×1
ecmascript-6 ×1
iframe ×1
javascript ×1
jestjs ×1
node.js ×1
polyfills ×1
socket.io ×1
testing ×1