热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在angular2中使用window对象但是vscode"找不到名称'窗口'"

如何解决《在angular2中使用window对象但是vscode"找不到名称'窗口'"》经验,为你挑选了1个好方法。

angular2在Visual Studio代码中编写了一个应用程序.最近,我将Visual Studio Code更新为1.10.2.但它突出显示window有错误.当我检查它时,我发现它说:

[ts]找不到名字'窗口'.

我的代码如下:

saveCustomIndex(customIndex:any,indexName:string){
    window.localStorage.setItem(indexName,JSON.stringify(customIndex));
}

截图

问题截图

我怎么处理这个?谢谢!



1> zurfyx..:

tsconfig.json,请确保"dom"您的库列表.

tsconfig.json 应该看起来或多或少像这样:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2016",
      "dom"
    ]
  }
}

编译器选项


推荐阅读
author-avatar
年轻的周末我做主
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有