由于某種原因,我無(wú)法讓全局變量計(jì)數(shù)器增加,即使它在發(fā)生 count++ 的函數(shù)內(nèi)增加也是如此。我的輸出結(jié)果在函數(shù)內(nèi)輸出的文本和函數(shù)外部的文本之間是不同的。知道我在這里做錯(cuò)了什么嗎?Survey.oncomplete 函數(shù)結(jié)果的每次迭代計(jì)數(shù)不應(yīng)該增加嗎?Survey .StylesManager .applyTheme("modern");var kn2 = "LwrHXqFRN_pszCopTKHF_Q"var kn3 = "exroCUoYl4wVzs7pKU_49w"var count = 0var keyname = ("kn" + count)var mapilink = "https://images.mapillary.com/" + (keyname) + "/thumb-1024.jpg";var json = { pages: [ { name: "page1", elements: [ { type: "image", name: "image", imageLink: (mapilink), imageHeight: 580, imageWidth: 640 }, { type: "html", name: (keyname), visible: false, html: (keyname) }, { type: "rating", name: "Walkability", title: "How walkable does this look to you" }, { type: "rating", name: "Saftey", title: "How safe does this look to you" }, { type: "rating", name: "Comfortability", title: "How comfortable does this look to you" } ] } ]}window.survey = new Survey.Model(json);var username = document.getElementById("user").value;survey .onComplete .add(function (result) { count ++; var PID = document.getElementById("user").value; var results = PID + "_" + (keyname) + ":\n" + JSON.stringify(result.data, null, 3) + (count) ; document .querySelector('#surveyResult') .textContent = results; survey.clear(); survey.render(); });$("#surveyElement").Survey({model: survey});
全局計(jì)數(shù)變量不增加
慕尼黑8549860
2023-09-28 17:26:07