接口测试支持更多请求方式

This commit is contained in:
zhangdaiscott 2020-12-09 17:36:00 +08:00
parent 54751428b2
commit 5863f00b26
1 changed files with 15 additions and 16 deletions

View File

@ -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(",}","}");
}