小编pac*_*ico的帖子

Chrome 扩展 sendResponse 回调值未发送

我正在编写一个与 gmail api 交互的 chrome 扩展(chrome 45 是我的版本),但在将消息从 background.js 发送到我的内容脚本时遇到问题。异步方面是问题所在。如何获取回调后发送的消息?

//---------in content script---------
chrome.runtime.sendMessage({ messageId: _id }, function (response) {    
    console.log('the respose.messagePayload is: ' + response.messagePayload); 
});

//---------in background script---------
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
    getMessage('me', request.messageId, function (payload) {
        //i want to send my response here
        //this executes and grabs the payload of data from the api, but isn't sending back the message to the content-script
        sendResponse({ messagePayload: payload }); 
    });
    //this synchronous call sends a message to the …
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome callback google-chrome-extension

6
推荐指数
1
解决办法
1034
查看次数

Linq .GroupBy()有计数

我有一张桌子需要在报告中总结.这是我的样本表.

                Orders
_____________________________________
CustomerId | CustomerName | OrderType 
___________|______________|__________ 
1          |     Adam     | Shoe
1          |     Adam     | Shoe
1          |     Adam     | Shoe
1          |     Adam     | Hat
1          |     Adam     | Hat
2          |     Bill     | Shoe
2          |     Bill     | Hat
3          |     Carl     | Sock
3          |     Carl     | Hat
Run Code Online (Sandbox Code Playgroud)

我试图总结这个在没有循环的情况下传回我的viewmodel.这是我试图实现的结果.

CustomerName | Shoe | Hat | Sock | Total Orders
------------ | ---- | --- | ---- | ------------
Adam         |   3  |  2  | …
Run Code Online (Sandbox Code Playgroud)

c# linq asp.net-mvc

1
推荐指数
2
解决办法
3620
查看次数