前端小火龙 2023-04-21 15:03 采纳率: 93.3%
浏览 55
已结题

chrome.runtime.onStartup用法

我在开发浏览器插件的时候,在background.js中使用了chrome.runtime.onStartup,但是我在启动浏览器的时候并没有执行,我代码是这样写的(background.js中)

chrome.runtime.onStartup.addListener(() => {
    console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
});

上面的console在浏览器启动的时候并没有执行,可以帮忙分析解决下吗

  • 写回答

2条回答 默认 最新

  • CSDN专家-showbo 2023-04-21 15:29
    关注

    onStartup

    chrome.runtime.onStartup.addListener(
      callback: function,
    )
    
    

    Fired when a profile that has this extension installed first starts up. This event is not fired when an incognito profile is started, even if this extension is operating in 'split' incognito mode.


    img

    官方的解释,某个Chrome配置第一次安装扩展时触发,并非每次启动浏览器时触发。卸载掉扩展,然后再安装试试

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月29日
  • 已采纳回答 4月21日
  • 创建了问题 4月21日