javascript - Chrome.notifications.update 未更新
问题描述
在后台脚本内的 chrome 扩展应用程序中,我正在尝试实现此代码,这是我的代码:
function foo(title, message, timeout) {
chrome.notifications.create({
type: 'progress',
iconUrl: 'img/GS icon.png',
title: title,
message: message || '',
progress: 0
}, function(id) {
// Automatically close the notification in 4 seconds by default
var progress = 0;
var interval = setInterval(function() {
if (++progress <= 100) {
chrome.notifications.update(id, {progress: progress}, function(updated) {
if (!updated) {
// the notification was closed
clearInterval(interval);
}
});
} else {
chrome.notifications.clear(id);
clearInterval(interval);
}
}, (timeout || 4000) / 100);
});
};
window.onload=function(){
foo('ttttitle','messsageee',10000);
}
但它始终保持在 1% 并且不动:
找不到问题。
清单.json:
{
"background": {
"scripts": ["js/background.js"],
"persistent": false
},
...
}
解决方案
推荐阅读
- codeception - 如果测试失败,如何在代码接收中回滚数据库?
- assembly - 关于汇编语言设置标志的逻辑问题
- php - 具有多个 slug 的 Laravel 路由在 React 中不起作用
- python - 整理熊猫实验的结果
- python - 将具有一个键和两个值的字典写入 csv 文件
- c# - 在 OData API 中修改表达式树
- python - 如何在不停止程序其余部分的情况下在 python 中进行延迟
- python - NCO/pynco:ncea 无法从 Python 中找到文件
- http - IIS:如何禁用 HTTP 方法 TRACE?
- ruby-on-rails-4 - 如何将 Carrierwave 文件迁移到 Rails 中另一个模型的列