elementUI 通用確認框


Util.vue

<script>
  import VueResource from 'vue-resource'

  function confirm(_this, operate, fun) {
    const h = _this.$createElement;
    _this.$msgbox({
      title: '操作確認',
      message: h('p', null, [
        h('span', null, '你是否確認 '),
        h('i', { style: 'color: #409EFF' }, operate)
      ]),
      showCancelButton: true,
      confirmButtonText: '確定',
      cancelButtonText: '取消',
      callback: action=>{
        if(action==='confirm')
          fun()
      }
    })
  }
  export default{
    confirm
  }
</script>

 

main.js相關代碼

import Utils from './Util.vue'

Vue.prototype.Utils = Utils

 

調用

        let fun = ()=>{
          this.$http.post(BASE_URL+'spider/run', row, {emulateJSON : true}).then((response) => {
            this.getData(this.currentPage)
          }, (response) => {})
        }
        this.Utils.confirm(this, '啟動爬蟲', fun)

 

效果

 


免責聲明!

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



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