vue的mixin注入

// 引入自mixin.js文件
export const GlobalMixin = {
  data() {
    return {
    }
  },
  methods: {
    deleteItem(title = 'Delete', content = 'Are you sure delete?') {
      return new Promise((resolve, reject) => {
        this.$confirm(content, title, {
          dangerouslyUseHTMLString: true,
          confirmButtonText: 'Confrim',
          cancelButtonText: 'Cancel',
          customClass: 'new-dialog-css'
        }).then(() => {
          resolve()
        }).catch(() => {
          reject()
        })
      })
    }
  }
}

使用

import { GlobalMixin } from '@/utils/mixin'

<label @click.stop="deleteCategory(scope.$index)" class="delete">Deletelabel>
export default {
	mixins: [GlobalMixin],
	methods: {
		deleteCategory(index) {
	      this.deleteItem().then(() => {
	        deleteMemberTagGroup(this.table_data[index].group_id).then(res => {
	          if (res.return_result) {
	            this.table_data.splice(index, 1)
	            this.$message({
	              message: 'Success',
	              type: 'success'
	            })
	            this.handleClose()
	          } else {
	            this.$message.error(res.msg)
	          }
	        }).catch(err => {
	          this.$message.error(err)
	        })
	      })
	    },
	}
}

你可能感兴趣的:(vue,vue)