您好,我已经编写了一个扩展,我想在每个平台/浏览器上运行它。它在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,
},
};