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)