0

我有以下代码,我用一个按钮添加了一个新通知......但实际上,我看到两个按钮,一个是我添加的,第二个是“设置”,当我点击“设置”按钮时什么也没发生。

chrome.notifications.create(`my-notification-${Date.now()}`, {
            iconUrl: "assets/images/1.png",
            imageUrl: "assets/images/1.png",
            type: "image",
            contextMessage: "ddsdsd",
            message: request.options.message,
            title: "titletitle",
            buttons: [{
                title: "Yes"
            }]
        }, function(context) {
           console.log("Last error:", chrome.runtime.lastError);

            alert(JSON.stringify(chrome.runtime.lastError));
        }); 

顺便说一句,它不适用于以下内容:

chrome.notifications.onButtonClicked.addListener(function (notifId, btnIdx) {

  if (btnIdx === 0) {
            alert('yes');
        } else if (btnIdx === 1) {
            alert('no');

        } else if (btnIdx === 2) {
            alert('12no');
        }
    });

也不工作:

chrome.notifications.onShowSettings.addListener(  () =>  {
          alert('settings');
        })

在此处输入图像描述

4

0 回答 0