gpt4 book ai didi

javascript - tslint 创建错误,但功能方面它工作正常

转载 作者:行者123 更新时间:2023-12-01 03:02:58 25 4
gpt4 key购买 nike

  • 我是 tslint 和 typescript 的新手。
  • 我正在尝试修复此错误。
  • 你能告诉我如何解决这个问题吗?
  • 我做了一些研究,但未能找到解决方案。
  • 提供下面的代码。

(no-typeof-undefined) app/components/sports.ts:避免 typeof x === 'undefined' 比较。更喜欢 x == undefined 或 x === undefined:typeof hen.waterFox != "undefined"

fever(hen, health): any {
let sky = "waterFoxDiplay";
let extensionType = {
".pdf": "pdfFox",

};
let captain = hen.waterName.captainOf(".");

sky = extensionType[hen.waterName.slice(captain).toLowerCase()];
if (typeof hen.waterFox != "undefined" && hen.waterFox != "") {
sky = hen.waterFox;
}
if (typeof sky === "undefined") {
sky = "newJokeFox";
}
let kendotxtMenu = "";
if (hen.isMobileJoke == true) //isMobileJokeUploaded
{
kendotxtMenu = "waterFoxDiplay";
}
if (hen.isMobileJoke == true && hen.MobileJokeID <= 0) //isMobileJokeUploaded
{

}
return "<span onclick=\"window.open('" + hen.waterName + "', 'popup', 'width=800,height=600,scrollbars=yes,resizable=no')\" class='" + sky + " displayInlineBlock " + kendotxtMenu + "'></span> <ul class='fileTypeHolder' id='fileTypeFoxs' style='display: none;'><li class='fileTypeHolderTitle'>Mobile water Type</li><li><span class='waterFox displayInlineBlock' (click)='browseFileType(Joke)'></span></li> <li><span class='xlsFox displayInlineBlock' (click)='browseFileType('xls')'></span></li> <li><span class='pptFox displayInlineBlock'(click)='browseFileType('ppt')'></span></li> <li><span class='pdfFox displayInlineBlock' (click)='browseFileType('pdf')'></span></li><li><span class='newJokeFox displayInlineBlock' (click)='browseFileType('newJoke')'></span></li><li><span class='mailFox displayInlineBlock' (click)='browseFileType('mail')'></span></li><li class='fileTypeHolderCloseBtn'> <button id='CloseBtn' class='commonBtn'>Close</button></ul>";
}

最佳答案

更改以下代码块

   if (typeof hen.waterFox != "undefined" && hen.waterFox != "") {
sky = hen.waterFox;
}
if (typeof sky === "undefined") {
sky = "newJokeFox";
}

进入

   if (hen.waterFox !== undefined && hen.waterFox != "") {
sky = hen.waterFox;
}
if (sky === undefined) {
sky = "newJokeFox";
}

关于javascript - tslint 创建错误,但功能方面它工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46355221/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com