更改ext.msg中的按钮Text,确认弹出窗口

eqfvzcg8  于 2022-09-26  发布在  其他
关注(0)|答案(1)|浏览(118)

我想把文本从“是”改为“是!!!”从“不”到“不!!!”我尝试了很多东西,但似乎都没用。找不到有关Sencha的任何文档,如果有人能帮上忙,谢谢

Ext.application({
    name: 'Fiddle',

    launch: function() {
Ext.Msg.confirm('Confirmation', "Do you want to cancel the order?", function(btnText){
                //btnText = {
                //    yes: "YES!!",
               //   no: "NO!!"
               //}, 
               //btnText.setText("YESSS!!"),    
                if(btnText === "yes"){
                    Ext.Msg.alert("Alert", "You have cancelled the order.");
               }
               else if(btnText === "no"){
                    Ext.Msg.alert("Alert", "You have confirmed 'No'.");

               }
            }, this);
    }
});

[解决方案]

Ext.application({
    name: 'Fiddle',
    launch: function() {                
        Ext.Msg.show({
        title: 'Title',
        message: 'Message',
        buttons: {
           yes: 'Cancel preAuth',
           no: 'Cancel the whole order',
           cancel: 'Do nothing!'
        },  
              fn: function(buttonValue, inputText, showConfig) {
                if(buttonValue === "yes"){
                    Ext.Msg.alert("Alert", "You have cancelled the order.");
               }
               else if(buttonValue === "no"){
                    Ext.Msg.alert("Alert", "You have confirmed 'No'.");
               }
            }, this);
    }
});
vx6bjr1n

vx6bjr1n1#

使用Ext.Msg.show而不是e1d1e,并为自定义按钮文本设置buttonText。检查文档并尝试以下代码:

Ext.Msg.show({
    title: 'Title',
    message: 'Message',
    buttons: Ext.Msg.YESNOCANCEL,
    buttonText: {
        yes: 'MyYes',
        no: 'MyNo',
        cancel: 'MyCancel'
    },
    icon: Ext.Msg.QUESTION,
    fn: function (btn) {
        if (btn === 'yes') {
            console.log('MyYes');
        } else if (btn === 'no') {
            console.log('MyNo');
        } else {
            console.log('MyCancel');
        }
    }
});

相关问题