From 0e8217bfb5341ecddf5690caa4fc2f1599cfc72d Mon Sep 17 00:00:00 2001 From: liudianxin Date: Thu, 3 Sep 2020 14:24:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E8=AF=A6=E6=83=85=E5=BC=BA?= =?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/general/codes.vue | 13 ++++++++++--- src/pages/workbench/fwgl/serviceDetail.vue | 6 ++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/general/codes.vue b/src/components/general/codes.vue index 870e38f..06860f6 100644 --- a/src/components/general/codes.vue +++ b/src/components/general/codes.vue @@ -45,9 +45,16 @@ export default { this.getValue(); } if (this.datas) { - this.aceEditor.setValue( - JSON.stringify(JSON.parse(this.datas), null, "\t") - ); + let obj = ""; + console.log(typeof JSON.parse(this.datas)); + try { + if (typeof JSON.parse(this.datas) == "object") { + obj = JSON.stringify(JSON.parse(this.datas), null, "\t"); + } + } catch (e) { + obj = this.datas; + } + this.aceEditor.setValue(obj); } }, watch: {}, diff --git a/src/pages/workbench/fwgl/serviceDetail.vue b/src/pages/workbench/fwgl/serviceDetail.vue index 755bc71..713b15c 100644 --- a/src/pages/workbench/fwgl/serviceDetail.vue +++ b/src/pages/workbench/fwgl/serviceDetail.vue @@ -692,7 +692,7 @@ export default { this.req_data = JSON.parse( data.req_fields || data.req_query || "[]" ); // 请求参数 - if (this.req_data.length === 0) { + if (this.req_data && this.req_data.length === 0) { this.$set(this.servicead_arr[1], "type", ""); this.$set(this.servicead_arr[1], "info", "无请求参数"); } @@ -704,11 +704,13 @@ export default { } this.$set(this.servicead_arr[3], "info", data.encode_method); // 编码格式 this.res_data = JSON.parse(data.res_fields || "[]"); // 响应参数 - if (this.res_data.length === 0) { + if (this.res_data && this.res_data.length === 0) { this.$set(this.servicead_arr[4], "type", ""); this.$set(this.servicead_arr[4], "info", "无响应参数"); } + console.log(data.res_fields_example) this.res_code_arr = data.res_fields_example || ""; // 响应示例 + console.log(this.res_code_arr) if (!this.res_code_arr) { this.$set(this.servicead_arr[5], "type", ""); this.$set(this.servicead_arr[5], "info", "无响应示例"); -- 2.26.0