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