鍍金池/ 問答/HTML/ elementUI中MessageBox的問題

elementUI中MessageBox的問題

在vue中定義了elementui中的messageBox全局函數(shù)

//確定消息彈框
export  let messageBox = (vm) => {
    const h = vm.$createElement;
    vm.$msgbox(
        {
        title: ' ',
        message: h('p', null, [
            h('span', {'class': 'queMark'}, '?'),
            h('p', {'class': 'text1'}, '確定保存'),
            h('p', {'class': 'text2'}, '保存后則更改當(dāng)頁信息,是否保存?')
        ]),
        confirmButtonText: '確認(rèn)',
        beforeClose: (action, instance, done) => {
            if (action === 'confirm') {
                
                done();
            } else {
            
                done();
            }

        }
    });
};

在組件中調(diào)用

//刪除
            handleDelete: function () {
                let flag = messageBox(this);
                console.log(flag)
            },

但是怎么能夠取到點擊確定或者取消的值呢?輸出一直是undefined;用return也不行,求高手指教

回答
編輯回答
厭惡我
 if (action === 'confirm') {
                console.log(action)
                done();
            } else {

//控制臺:點擊確定之后 'confirm'

2018年1月27日 23:25