【发布时间】:2022-01-19 07:50:27
【问题描述】:
我正在开发一个创建 google chrome 扩展程序的项目,并且我正在其中使用 chrome API。现在,我正在尝试在更新选项卡时使用我的 handleTabUpdate 函数。但是,我收到了Unchecked runtime.lastError: No tab with id: 60
我该如何解决这个问题?这是我的代码:
chrome.tabs.onUpdated.addListener(handleTabUpdate)
function handleTabUpdate(tabId, info) {
if (info.status === 'loading') {
store.dispatch({ type: 'RESET_TABHOSTS' })
chrome.tabs.get(tabId, (activeTab) => {
if (tabId === store.getState().currentTab['id']) {
store.dispatch({ type: 'ACTIVE_TAB', payload: activeTab })
}
})
}
}
【问题讨论】:
标签: javascript typescript google-chrome-extension chrome-extension-manifest-v3