返回值是否在实际代码块之前执行?

时间:2019-02-02 06:23:58

标签: javascript node.js

我最近开始在某些项目中使用Node.js,但遇到了问题。我正在使用Glitch托管我的应用程序,该应用程序无非就是从Facebook消息中获取字符串,将该字符串授予电子表格,然后返回匹配的行。

我遇到的问题是,对工作表的get请求必须太慢,因为该函数在找到任何内容之前会返回null值。这是核心块:

const weatherButton = document.getElementsByTagName("BUTTON")[0];
const currentTemp = document.getElementsByClassName("weather__main--temp")[0];
const currentDayElement = document.getElementsByClassName("weather__lower--day")[0];
const futureDays = document.getElementsByClassName("weather__item--day");

weatherButton.addEventListener("click", () => {
	const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
	let now = new Date();
	let currentDayIndex = now.getDay();
	currentDayElement.innerHTML = days[currentDayIndex];
	//Adding days for futurecast
	for( let i = 0; i < 6; i++ ) {
		if( currentDayIndex >= 6 ) {
			currentDayIndex = 0;
			futureDays[0].innerHTML += '<div class="day">' + days[currentDayIndex] + '</div>';
		} else {
			futureDays[0].innerHTML += '<div class="day">' + days[currentDayIndex + 1] + '</div>';
			currentDayIndex++;
		}
	};
});
返回

数据,然后才能通过search(arg,arg)函数对其进行更新。控制台显示处理顺序为:

weather__main--temp
<div class="weather__main--temp"></div>
weather__lower--day
<div class="weather__lower--day"></div>
weather__item--day
<div class="weather__item--day"></div>
button
<button id="button" style="width:100px; height:25px;">Click me!</button>

认证很好,搜索也很好,除此之外一切都很好。

谢谢。

0 个答案:

没有答案