美好的一天,我已经写了一个扩展程序,我想在每个平台/浏览器上运行。它与chrome和firefox工作正常但是在Windows 10上的ie-edge得到了错误。它一直没有定义抛出chrome。有没有办法让它定义,因为我一直在使用我的扩展。
由于
export default {
browserAction: {
onClicked: chrome.browserAction !== undefined ? chrome.browserAction.onClicked : undefined,
setBadgeText: chrome.browserAction !== undefined ? chrome.browserAction.setBadgeText : undefined,
setTitle: chrome.browserAction !== undefined ? chrome.browserAction.setTitle : undefined,
setIcon: chrome.browserAction !== undefined ? chrome.browserAction.setIcon : undefined,
},
extension: {
getURL: chrome.extension !== undefined ? chrome.extension.getURL : undefined,
},
runtime: {
onMessage: chrome.runtime.onMessage || browser.runtime.onMessage,
reload: chrome.runtime.reload,
sendMessage: chrome.runtime.sendMessage,
},
tabs: {
create: chrome.tabs !== undefined ? chrome.tabs.create : undefined,
executeScript: chrome.tabs !== undefined ? chrome.tabs.executeScript : undefined,
get: chrome.tabs !== undefined ? chrome.tabs.get : undefined,
onActivated: chrome.tabs !== undefined ? chrome.tabs.onActivated : undefined,
onUpdated: chrome.tabs !== undefined ? chrome.tabs.onUpdated : undefined,
query: chrome.tabs !== undefined ? chrome.tabs.query : undefined,
remove: chrome.tabs !== undefined ? chrome.tabs.remove : undefined,
sendMessage: chrome.tabs !== undefined ? chrome.tabs.sendMessage : undefined,
},
webRequest: {
onBeforeRedirect: chrome.tabs !== undefined ? chrome.webRequest.onBeforeRedirect : undefined,
},
};