我试图调用一个函数两次,但是使用当前代码我跳过getPoints()函数并调用setInterval中的getPoints()函数。我试图让它调用getPoints()函数,然后调用setInterval中的那个。
var background;
// background page
background = chrome.extension.getBackgroundPage();
// get totals
getPoints(background.localStorage.points);
// update every 30 seconds
setInterval(function() {
console.log("func");
getPoints(background.localStorage.points);
}, 30000);
答案 0 :(得分:1)
试试这个:
window.onload = function() {
var background;
// background page
background = chrome.extension.getBackgroundPage();
// get totals
getPoints(background.localStorage.points);
// update every 30 seconds
setInterval(function () {
console.log("func");
getPoints(background.localStorage.points);
}, 30000);
};