1、原生axios使用

<script>
import Vue from 'vue';
import axios from 'axios';
axios.defaults.baseURL = 'http://127.0.0.1:3000/jeecg-boot/sys/annountCement';
// Vue.prototype.$http = axios;
import { ACCESS_TOKEN } from "@/store/mutation-types" axios.interceptors.request.use(config =>{
console.log("enter into axios.interceptors");
const token = Vue.ls.get(ACCESS_TOKEN);
// this.headers = { authorization: 'authorization-text',"X-Access-Token":token }
// config.headers.Authorization = window.sessionStorage.getItem('X-Access-Token');
config.headers['X-Access-Token'] = token;
return config;
}) const columns = [
{ title: 'Full Name', width: 100, dataIndex: 'name', key: 'name', fixed: 'left' },
{ title: 'Age', width: 100, dataIndex: 'age', key: 'age', fixed: 'left' },
{ title: 'Column 1', dataIndex: 'address', key: '1', width: 150 },
{ title: 'Column 2', dataIndex: 'address', key: '2', width: 150 },
{ title: 'Column 3', dataIndex: 'address', key: '3', width: 150 },
{ title: 'Column 4', dataIndex: 'address', key: '4', width: 150 },
{ title: 'Column 5', dataIndex: 'address', key: '5', width: 150 },
{ title: 'Column 6', dataIndex: 'address', key: '6', width: 150 },
{ title: 'Column 7', dataIndex: 'address', key: '7', width: 150 },
{ title: 'Column 8', dataIndex: 'address', key: '8' },
{
title: 'Action',
key: 'operation',
fixed: 'right',
width: 100,
scopedSlots: { customRender: 'action' },
},
]; const data = [];
for (let i = 0; i < 100; i++) {
data.push({
key: i,
name: `Edrward ${i}`,
age: 32,
address: `London Park no. ${i}`,
});
} export default {
name: 'antdesignvue',
data() {
return {
data,
columns,
visible: false, headers: { },
token:{ }
}
},
methods: {
showModal() {
this.visible = true
},
handleOk(e) {
console.log(e);
this.visible = false
}, async getlist() {
//const result = await axios.get('list?_t=1582775652&column=createTime&order=desc&field=id,,,titile,msgCategory,sender,priority,msgType,sendStatus,sendTime,cancelTime,action&pageNo=1&pageSize=10');
const result = await axios.get('list'); console.log(result);
console.log(result.data);
console.log(result.data.result.records);
}, },
created(){
console.log("created!");
this.getlist();
} }

2、getAction封装get请求

api/manage.js

//get
export function getAction(url,parameter) {
return axios({
url: url,
method: 'get',
params: parameter
})
}

......

import { getAction } from '@/api/manage';

......

created(){
console.log("created!");
//this.getlist();
getAction('http://127.0.0.1:3000/jeecg-boot/sys/annountCement/list').then((res) => {console.log(res)});
}

3、httpAction封装post请求

api/manage.js

//post method= {post | put}
export function httpAction(url,parameter,method) {
return axios({
url: url,
method:method ,
data: parameter
})
}

......

 import { getAction,httpAction } from '@/api/manage';

......

created(){
console.log("created!");
httpAction('http://127.0.0.1:3000/jeecg-boot/sys/annountCement/edit',this.formData,'put').then((res)=>{console.log(res)});
}



4、X-Access-Token

jeecg请求时附加token

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>

jeecg /ant-design-vuepro 前端使用的更多相关文章

  1. ant design pro/前端/JS:实现本地运行https

    工具:github---mkcert 用于生成本地证书 ant p版本:1.0.0 这里我只说如何给antp部署https,以及会遇到的问题解决,其他请看原文参考 1.用mkcert生成证书,去git ...

  2. jeecg ant design vue 一些收藏

    1关于 进来清除上次记录 找到src/permission.js下的

  3. jeecg ant design vue一级菜单跳到外部页面——例如跳到百度

    需求:点击首页跳到百度新打开的页面 找到SideMenu.vue   对应的inde.js找到renderMenuItem 函数.加一个判断 if(menu.meta.url=='https://ww ...

  4. 使用Vue-Cli搭建Ant Design Vue前端开发环境

    如果文章有帮助到你,还请点个赞或留下评论 搭建脚手架 环境准备 nodeJS vue-cli 如果没有安装点击此处查看安装方法 进入 vue ui 1.打开终端,输入命令 vue ui 2.选择项目存 ...

  5. Ant design在vue,react的引入

    文章地址: https://www.cnblogs.com/sandraryan/ 最近由于 一些不可描述的原因 要研究一下Ant design这个前端框架. 祭上官网: https://ant.de ...

  6. (二)React Ant Design Pro + .Net5 WebApi:前端环境搭建

    首先,你需要先装一个Nodejs,这是基础哦.如果没有这方面知识的小伙伴可以在园子里搜索cnpm yarn等关键字,内容繁多,此不赘述,参考链接 一. 简介 1. Ant Design Pro v5 ...

  7. 使用selenium操作ant design前端的页面,感觉页面没加载完

    因需要收集页面数据,遂准备使用selenium爬取瓦斯阅读页面, 瓦斯网站使用的是ant design,元素定位非常困难,页面元素都没有ID,现在还只是能做到操作登录,不能自动打开订阅,查询某公众号, ...

  8. 前端自动分环境打包(vue和ant design)

    现实中的问题:有时候版本上线的时候,打包时忘记切换环境,将测试包推上正式服务器,那你就会被批了. 期望:在写打包的命令行的时候就觉得自己在打包正式版本,避免推包时候的,不确信自己的包是否正确. 既然有 ...

  9. Vue.js高效前端开发 • 【Ant Design of Vue框架进阶】

    全部章节 >>>> 文章目录 一.栅格组件 1.栅格组件介绍 2.栅格组件使用 3.实践练习 二.输入组件 1.输入框组件使用 2.选择器组件使用 3.单选框组件使用 4.实践 ...

  10. Vue.js高效前端开发 • 【Ant Design of Vue框架基础】

    全部章节 >>>> 文章目录 一.Ant Design of Vue框架 1.Ant Design介绍 2.Ant Design of Vue安装 3.Ant Design o ...

随机推荐

  1. Mysql部分存储引擎介绍

    Mysql存储引擎 什么是存储引擎 mysql中建立的库 --> 文件夹 库中建立的表 --> 文件 ​ 现实生活中我们用来存储数据的文件有不同的类型,每种文件类型对应各自不同的处理机制: ...

  2. Base64编码和其在图片的传输的应用

    Base64 [原文链接] 目前Base64已经成为网络上常见的传输8Bit字节代码的编码方式之一.做支付系统时,系统之间的报文交互都需要使用Base64对明文进行转码,然后再进行签名或加密,之后再进 ...

  3. SequoiaDB巨杉数据库入门:快速搭建流媒体服务器

    使用SequoiaDB的分布式文件系统搭建流媒体服务器 介绍 如今使用移动互联网的年轻人开始越来越多使用短视频展示自我,而流媒体则是支撑在线视频播放的核心技术.当我们开始构建流媒体站点时,往往面临最大 ...

  4. LED Decorative Light Supplier - LED Environmental Decorative Lighting Application

    Creating ambient lighting in the home can bridge the gap between the internal world and the outside ...

  5. [一本通学习笔记] 字典树与 0-1 Trie

    字典树中根到每个结点对应原串集合的一个前缀,这个前缀由路径上所有转移边对应的字母构成.我们可以对每个结点维护一些需要的信息,这样即可以去做很多事情. #10049. 「一本通 2.3 例 1」Phon ...

  6. 利用Cadence PCB SI分析特性阻抗变化因素

    1.概要 在进行PCB SI的设计时,理解特性阻抗是非常重要的.这次,我们对特性阻抗进行基础说明之外,还说明Allegro的阻抗计算原理以及各参数和阻抗的关系. 2.什么是特性阻抗? 2.1 传送线路 ...

  7. java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!

    问题描述 java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based! 红色部分报错 for ( ...

  8. 显示目录文件命令 - ls

    1) 命令名称:ls 2) 英文原意:list 3) 命令所在路径:/bin/ls 4) 执行权限:所有用户 5) 功能描述:显示目录文件 6) 语法: ls 选项[-ald][文件或目录] -a 显 ...

  9. NAND FLASH驱动框架以及程序实现

    1.NAND FLASH的硬件连接: 实验用的NAND FLASH芯片为K9F2G08U0C,它是三星公司的存储芯片,它的大小为256M.它的接线图如下所示: 它的每个引脚的分别为LDATA0-LDA ...

  10. NlogN复杂度寻找数组中两个数字和等于给定值

    算法导论:22页2.3-7 描述一个运行时间为O(nlogn)的算法,找出n个元素的S数组中是否存在两个元素相加等于给定x值 AC解: a=[1,3,6,7,9,15,29] def find2sum ...