首页 > 技术文章 > jeecg请求时附加token

HQ0422 2019-09-05 08:50 原文



1.引入token依赖

  import { ACCESS_TOKEN } from "@/store/mutation-types"
  import Vue from 'vue'

2.在data的return中声明headers和token字段

  headers: { },

  token:{ }

3.在created(){ }中给this.header赋值

  created(){//加载事件

    const token=Vue.ls.get(ACCESS_TOKEN);

    this.headers={ authorization: 'authorization-text',"X-Access-Token":token }
  }

4.引用示例:

  <a-upload :action="请求地址" :data="token" :headers="headers"></a-upload>

 

推荐阅读