在 Visual Studio 2019 社区版中。16.5.4 带有导入和导出声明的打字稿文件会显示警告。
如果未打开文件,则不会显示警告。但是当我打开一个打字稿文件时,就会出现警告。
它是 angular 9 的入门模板。我添加了一些包(bootstrap、jwt-decode、fontawesome、jquery、popper.js)
当我运行代码时:
public onResize(event: Event) {
console.log(event.target.innerWidth);
//--solution--
//var w = event.target as Window;
//console.log(w.innerWidth);
}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
Property innerWidth does not exist on type EventTarget
Run Code Online (Sandbox Code Playgroud)
我想避免在TypeScript中扩展类型(如此处所述,类型'EventTarget'上不存在属性'value'),所以我将event.target其强制转换为Window类。我不确定是否要上适当的课。我应该选哪个班?如何找到应上的适当班级?
我想为 angular 5 应用程序安装npm bootstrap-select所以我使用 npm 安装了它
npm install bootstrap-select
Run Code Online (Sandbox Code Playgroud)
然后我安装了所需的依赖项:
npm install jquery
npm install popper.js --save
Run Code Online (Sandbox Code Playgroud)
角度cli.json:
"apps": [
{
"styles": [
"styles.css"
],
"scripts": [ "../node_modules/jquery/dist/jquery.min.js" ],
}
],
Run Code Online (Sandbox Code Playgroud)
我的 package.json 是(我从列表中删除了一些包):
"dependencies": {
(...)
"@ng-bootstrap/ng-bootstrap": "^1.1.0",
"bootstrap": "^4.1.1",
"bootstrap-select": "^1.13.2",
"jquery": "^3.3.1",
"ng-multiselect-dropdown": "^0.2.1",
"popper.js": "^1.14.4",
}
Run Code Online (Sandbox Code Playgroud)
在 html 文件中,我添加了代码:
<ng-template #modalWindow let-c="close" let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title">Options</h4>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<select id="myspID" #selectPickerRef class="selectpicker …Run Code Online (Sandbox Code Playgroud) typescript ×2
angular ×1
angular5 ×1
bootstrap-4 ×1
casting ×1
eslint ×1
import ×1
javascript ×1