我有一些进度通知,我只想更新它,但它从 0% 到 1%,然后保持在 1%。
这是我的代码:
var notifId = uuidv4();
var i = 0;
var notifOptions = {
type: 'progress',
iconUrl: 'img/GS icon.png',
title: 'test',
progress: i,
requireInteraction: true,
message: 'Downloading...',
buttons: [{
title: 'Abort download'
}]
};
chrome.notifications.create(notifId, notifOptions);
setInterval(function () {
chrome.notifications.update(notifId, {
progress: ++i % 100
}, function () {});
},
1000);
where
//create a unique id for eatch notification
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
有什么问题吗?为什么它停留在1%?
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)