首页 > 解决方案 > chrome 扩展 - 为什么 'catch' 不执行?

问题描述

我正在使用来自chrome 开发人员网站的示例, 但问题是不执行?

/// background.js

chrome.tabs.onActivated.addListener(activeInfo => move(activeInfo));

async function move(activeInfo) {
  try {
    await chrome.tabs.move(activeInfo.tabId, {index: 0});
    console.log('Success.');
  } catch (error) {
    if (error == 'Error: Tabs cannot be edited right now (user may be dragging a tab).') {
      setTimeout(() => move(activeInfo), 50);
    }
  }
}

标签: google-chrome-extension

解决方案


推荐阅读