vue中對element的彈框messagebox的二次封裝


在vue中對確認框的二次封裝

使用場景:在頁面中做某些需要警告的操作時的彈框提示


1、在utils文件夾下新建一個confirm.js文件來對messageBox的封裝,內容如下:

/** confirm.js */
import { MessageBox } from 'element-ui'

export function handleCofirm(text = '確定執行此操作嗎?', type = 'warning') {
  return MessageBox.confirm(text, '提示', {
    confirmButtonText: '確定',
    cancelButtonText: '取消',
    type: type,
    center: true
  })
}

2、使用

import { handleCofirm } from '@/utils/confirm'
export default {
    deleteDomain(row) {
      handleCofirm('確認刪除該標簽嗎?', 'warning',).then(res => {
         // 
      }).catch(err => {
        console.log('err', err) // cancel
        // 
      })
    }
  
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM