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

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日

悬赏问题

  • ¥15 为什么我按照电路图做出的仿真和实物都不能使用
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web