mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-10-28 07:05:25 +00:00
devtools界面和content.js进行交互
This commit is contained in:
@@ -67,11 +67,14 @@
|
||||
if (!this.longConn) {
|
||||
console.log("[popup] 初始化长连接");
|
||||
this.longConn = chrome.runtime.connect({name: "popup"});
|
||||
this.longConn.onMessage.addListener(function (data, info) {
|
||||
debugger
|
||||
})
|
||||
this.longConn.onMessage.addListener(function (data, sender) {
|
||||
this._onLongConnMsg(data, sender);
|
||||
}.bind(this))
|
||||
}
|
||||
},
|
||||
_onLongConnMsg(data, sender) {
|
||||
console.log(this.title);
|
||||
},
|
||||
onMsgToBg() {
|
||||
// 因为webpack的原因,这种方式可能拿不到里面的function, var
|
||||
// chrome.extension.getBackgroundPage();
|
||||
@@ -82,7 +85,6 @@
|
||||
});
|
||||
},
|
||||
onSendMsg() {
|
||||
debugger
|
||||
if (this.longConn) {
|
||||
this.longConn.postMessage({send: "hello"});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user