The unique ID to assign to this item. Mandatory for event pages. Cannot be the same as another ID for this extension.
报这种错误的就是没有定义id 下面的例子 chrome.contextMenus.create 给id 定义一个值
//mv2 右键选择
chrome.contextMenus.create({
id:"erlyun_page_collect",
title: "云书签收藏",
//contexts: ['selection'],
click: function(){}
});
mv2里面有click事件,mv3就会报错了
contextMenus.create(object createProperties, optional function callback): Error at parameter 'createProperties': Unexpected property: 'onClicked'.
下面改成mv3的例子
//初始化插件|第一次安装插件
chrome.runtime.onInstalled.addListener(function(){
//右键选择
chrome.contextMenus.create({
id:"erlyun_page_collect",
title: "云书签",
//contexts: ['selection'],
});
});
chrome.contextMenus.onClicked.addListener(function(info,tab) {
if(info.menuItemId == 'erlyun_page_collect'){
//@todo 你需要的右键之后的逻辑
}
});
一旦创建上下文菜单就会在您的扩展程序中持久存在,最好只定义一次:当您的扩展程序安装(或更新)时,并在每次加载后台页面时添加侦听器。