chrome.runtime.sendMessage无法接收响应

时间:2018-06-28 13:58:23

标签: google-chrome-extension

这是我的后台脚本:

chrome.runtime.onMessage.addListener(async function(message, sender, 
sendResponse){
    let options = message.options
    let res = await axios(options)
    alert(JSON.stringify(res.data.msg[0]))     --mark1
    sendResponse({res:res})
})

这是我的内容脚本:

 chrome.runtime.sendMessage( options:options}, 
    function(res){
        console.log(res)    --mark2
    })

当chrome执行内容脚本时,mark1会警告正确的结果。 但是在mark2上,res是不确定的。这让我非常困惑,我找不到我的代码有什么问题。

0 个答案:

没有答案
相关问题