From 5863f00b26fb302ca64bea138908b28ff8d4601b Mon Sep 17 00:00:00 2001 From: zhangdaiscott <zhangdaiscott@163.com> Date: Wed, 9 Dec 2020 17:36:00 +0800 Subject: [PATCH] 接口测试支持更多请求方式 --- ant-design-vue-jeecg/src/views/jeecg/InterfaceTest.vue | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/ant-design-vue-jeecg/src/views/jeecg/InterfaceTest.vue b/ant-design-vue-jeecg/src/views/jeecg/InterfaceTest.vue index 117f7dc..8b30f73 100644 --- a/ant-design-vue-jeecg/src/views/jeecg/InterfaceTest.vue +++ b/ant-design-vue-jeecg/src/views/jeecg/InterfaceTest.vue @@ -1,10 +1,12 @@ <template> <a-card :bordered="false"> - <a-row> + <a-row style="margin-top: 20px"> <a-col :md="2" :sm="4"> <a-select defaultValue="POST" style="width: 90px" @change="handleChange" size="large"> <a-select-option value="POST">POST</a-select-option> - <!--<a-select-option value="GET">GET</a-select-option>--> + <a-select-option value="GET">GET</a-select-option> + <a-select-option value="PUT">PUT</a-select-option> + <a-select-option value="DELETE">DELETE</a-select-option> </a-select> </a-col> <a-col :md="22" :sm="20"> @@ -19,7 +21,7 @@ <a-tabs defaultActiveKey="2"> <a-tab-pane tab="params" key="2"> - <textarea style="width:100%;font-size: 16px;font-weight:500" :rows="13" @input="changeVal"> + <textarea style="width:100%;font-size: 16px;font-weight:500" :rows="13" @blur="changeVal"> </textarea> </a-tab-pane> </a-tabs> @@ -33,7 +35,7 @@ </a-card> </template> <script> - import { postAction,getAction } from '@/api/manage' + import { axios } from '@/utils/request' import { ACCESS_TOKEN } from "@/store/mutation-types" import Vue from 'vue' export default { @@ -49,28 +51,25 @@ methods: { onSearch (value) { let that = this + if(!value){ + that.$message.error("请填写路径") + return false + } this.resultJson = {}; - if("POST"===this.requestMethod.toUpperCase()){ - postAction(value,this.paramJson).then((res)=>{ + axios({ + url: value, + method: this.requestMethod, + data: this.paramJson + }).then((res) => { console.log(res) this.resultJson = res }).catch((err) => { that.$message.error("请求异常:"+err) }) - }else { - getAction(value,this.paramJson).then((res)=>{ - console.log(res) - this.resultJson = res; - }).catch((err) => { - that.$message.error("请求异常:"+err) - }) - } }, changeVal(e){ try { let json = e.target.value; - json = json.replace(/\n/g,""); - json = json.replace(/\s*/g,""); if(json.indexOf(",}")>0){ json = json.replace(",}","}"); } -- libgit2 0.22.2