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)
效果