首页 > 其他 > 详细

前端调用路由导出数据方法记录

时间:2020-05-28 14:11:29      阅读:84      评论:0      收藏:0      [点我收藏+]
1.登录接口调用之后赋值token
  this.$cookie.set(‘token‘, data.token)
 
 2.this.$http.BASE_URL :配置的全局基础路由
封装ajax的页面:
// 跨域请求,允许保存cookie
axios.defaults.withCredentials = true
axios.defaults.headers = {‘Content-Type‘: ‘application/json; charset=utf-8‘}
// 非生产环境 && 开启代理, 接口前缀统一使用空‘‘前缀做代理拦截!
const BASE_URL = process.env.NODE_ENV !== ‘production‘ && process.env.OPEN_PROXY ? ‘/api‘ : window.SITE_CONFIG.baseUrl
// 对面暴露的基础请求路径
axios.BASE_URL = BASE_URL
 
3.导出的API:/api/ec/amo/sys/scheduling/anchor/export
方法:
 <el-button type="primary" @click="exportFun()">导出数据</el-button>
// 导出数据
      exportFun() {
        let exporthref = this.$http.BASE_URL + `/api/ec/amo/sys/scheduling/anchor/export?order=${this.searchForm.order}&liveStatus=${this.searchForm.liveStatus}&brandId=${this.searchForm.brandId}&token=${this.$cookie.get(‘token‘)}`
        window.open(exporthref)
      },

前端调用路由导出数据方法记录

原文:https://www.cnblogs.com/wssdx/p/12980410.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!