gpt4 book ai didi

javascript - 是否有任何 JavaScript 方法来停止函数工作

转载 作者:行者123 更新时间:2023-11-30 20:52:30 24 4
gpt4 key购买 nike

我有一个函数,它有一个 if 语句和一个 onclick 函数。我希望当 if 语句为真时,整个函数将不起作用。我试过 return false 但它对我不起作用

showLogo: function(row) {
var a = 0;
window.onclick = (e => {
let element = e.target.className || e.srcElement.className
let element1 = e.target || e.srcElement
if (element1.localName == "li" || element == "pagination-previous" || element == "pagination-next" || element === "pagination-link" || element === "icon" || element === "fa fa-angle-right fa-lg" || element === "b-table" || element === "level" || element === "pagination" || element === "fa fa-angle-left fa-lg") {
this.logo = false
}
});
if (window.innerWidth > 1024) {
this.logo = true;
this.color = false;
this.istabModalActive = false;
this.name = row.fileName;
this.dimension = row.width + ' x ' + row.height
this.width = 0;
this.height = 0;
this.src = row.path;
this.icon = row.iconsrc;
this.dlsrc = row.path;
this.contentType = row.contentType;
this.typeshow = row.contentType.split("/")[1].toUpperCase();
this.type = row.contentType.split("/")[1];
this.icons = 'dist/' + this.type + '.svg';
this.assetsid = row.index;
this.size = row.size;
this.activerow = row;
this.fileid = row.id;
this.assetsid = row.id;
this.activerow = row;
} else {
this.logo = true;
this.color = false;
this.istabModalActive = true;
this.filesarr = row;
this.name = row.fileName;
this.dimension = row.width + ' x ' + row.height
this.size = row.size;
this.src = row.path;
this.icon = row.iconsrc;
this.dlsrc = row.path;
this.typeshow = row.contentType.split("/")[1].toUpperCase();
this.type = row.contentType.split("/")[1];
this.icons = row.iconsrc;
this.fileid = row.id;
this.assetsid = row.id;
this.activerow = row;
}

}

最佳答案

showLogo:function(row){
var a = 0;
var flag = 0;
window.onclick = (e => {
let element = e.target.className || e.srcElement.className
let element1 = e.target || e.srcElement
if (element1.localName == "li" || element == "pagination-previous" || element == "pagination-next" || element === "pagination-link" || element === "icon" || element === "fa fa-angle-right fa-lg" || element === "b-table"|| element === "level"|| element === "pagination" || element === "fa fa-angle-left fa-lg") {
this.logo = false;
flag = 1;
}


});
if(window.innerWidth> 1024 && flag == 0)
{
this.logo = true;
this.color = false;
this.istabModalActive = false;
this.name = row.fileName;
this.dimension = row.width +' x '+row.height
this.width = 0;
this.height = 0;
this.src = row.path;
this.icon = row.iconsrc;
this.dlsrc = row.path;
this.contentType = row.contentType;
this.typeshow = row.contentType.split("/")[1].toUpperCase() ;
this.type = row.contentType.split("/")[1];
this.icons = 'dist/'+this.type+'.svg';
this.assetsid=row.index;
this.size = row.size;
this.activerow = row;
this.fileid=row.id;
this.assetsid=row.id;
this.activerow = row;
}
else if(flag == 0) {
this.logo = true;
this.color = false;
this.istabModalActive = true;
this.filesarr=row;
this.name = row.fileName;
this.dimension = row.width +' x '+row.height
this.size = row.size;
this.src = row.path;
this.icon = row.iconsrc;
this.dlsrc = row.path;
this.typeshow = row.contentType.split("/")[1].toUpperCase() ;
this.type = row.contentType.split("/")[1];
this.icons = row.iconsrc;
this.fileid=row.id;
this.assetsid=row.id;
this.activerow = row;
}

},

关于javascript - 是否有任何 JavaScript 方法来停止函数工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48018426/

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