我已经搜索过这个但没有运气。我想为 Google Chrome 扩展中的每个父菜单创建两个子菜单。但是我的代码只在上下文为“页面”时创建子菜单。这是我目前正在尝试的代码:
var contexts = ["page","link","image"];
for (var i = 0; i < contexts.length; i++) {
var context = contexts[i];
var title = "";
title = "Do something with this "+context;
var id = chrome.contextMenus.create({"title": title, "contexts":[context]});
var child1 = chrome.contextMenus.create({"title": "someThing1", "parentId": id, "onclick": onClickFunc});
var child2 = chrome.contextMenus.create({"title": "someThing2", "parentId": id, "onclick": onClickFunc});
}
任何想法??