English 中文(简体)
我在“国库”职能上遇到了一个错误,即:不重新分配——回返声明不应包含派任。 我如何解决这个问题?
原标题:I am getting an error on Count function - eslint: no-return assign - Return statement should not contain assignment. How do I resolve this?

我的文字基本上根据网页信息建立了超链接。 当用户点击该超级链接时,它将将其送到一个图像页面。 现在,我想点击这一超链接,把总点数(增量)显示到另一页。 我所尝试的是,在座标点数时,低于代码,但我正在发现一个错误:

eslint: no-return assign - Return statement should not contain assignment.

而且,如果有人能帮助我解决这个问题,能否在另一页显示这一看法? 如果我重新翻过这页,那么,罪状不会重新set?

我将附上你审查的部分文字。 非常感谢。 一天!

//This will create that link into a page
let link = document.createElement("a");
            var linkText = document.createTextNode(images2[j].name);               
            link.appendChild(linkText);
            link.title = images2[j].name;
            link.href = images2[j].image_src;
            link.target =  _blank ;
            document.querySelector( [class^="testui_tabs-content"] ).prepend(link);

let eventListenerFunction = (e) => {log( A link was clicked ); }
            document.querySelectorAll( [class^="testui_tabs-content"] ).forEach(linkText => {
            link.addEventListener("click", eventListenerFunction );
});


//This will log user clicks to a Slack Channel

function log(msg){

const ticketurl = window.location.href;
const url =  https://hooks.slack.com/workflows/Test ;
const headers = { Content-Type :  application/x-www-form-urlencoded };

let data = `${msg}, ${ticketurl}, ${new Date().toISOString()}, v${GM_info.script.version}`;

data = { Content : data};
request( POST , url,   , headers, data);

};

//Counts the click on the hyperlink with error
var count = (function () {        
var counter = 0;
return function () {return counter +=1;}
    
})();

function displaycount(){
document.getElementById("log").innerHTML = count();

})();
问题回答

first, solve your eslint error -

各位见<代码>return Counter +=1。 系指将<代码>counter指定为counter + 1,然后退还该数值。 如果你不想要这种错误,那么你就不需要分配:

counter += 1;
return counter;

现在你们想要把价值节省到另一页? 有许多办法可以节省网页和复读后的数据。 阅读https://developer.mozilla.org/en-US/docs/Web/API/Window/ localStorage” rel=“nofollow noreferer” localStorage





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签