VUE封装js方法

// 引入router
import router from '../../router/index';
import Vue from 'vue'
//axios
import axios from 'axios';
//需要跳转路由的
function toRouter(url, parameter) {
  router.push({
    path: url,
    query: parameter
  });
};
// 删除
function dele(url, parameter, spring_box) {
  var bool = false
  if (parameter instanceof Array) {
    if (parameter.length > 0) {
      bool = true
    }else{
      bool = false
    }
  } else {
    bool = true
  }
  if (bool) {
    Vue.prototype.$confirm(spring_box, '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {
      axios
        .post(url, {
          id: [parameter.id],
          status: parameter.state ? parameter.state : ''
        })
        //接口返回数据
        .then(res => {
          if (res.data.code == 1) {
            Vue.prototype.$message.success(res.data.msg);
            router.go(0)
          } else {
            Vue.prototype.$message.error(res.data.msg);
          }
        })
        .catch(() => {
          Vue.prototype.$message.error("删除失败,请重试");
        });
    }).catch(() => {
     
    });
  }


}
export default {
  toRouter,
  dele
};

外部引用

import perm from "../../../components/Hidden/permission"; //引入按钮公共方法
 <el-button :type="item.button_style==1?'senior':'default'" 
 @click="perm[item.button_func](item.homeuri)" 
 v-for="(item,index) in topbtn" :key="index">{{item.title}}</el-button>
mounted: function() {
	 this.perm=perm
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值