From cf5d7bcbabbcaef3e5743b46da0dc65bf1d17abc Mon Sep 17 00:00:00 2001 From: hulutech-web Date: Tue, 29 Oct 2024 09:48:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=94=E5=9B=9E=E4=B8=BAni?= =?UTF-8?q?l=E6=97=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http_result.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/http_result.go b/http_result.go index 919308c..9dc0368 100644 --- a/http_result.go +++ b/http_result.go @@ -41,6 +41,10 @@ func (h *HttpResult) Success(message string, data interface{}) http.Response { if message == "" { message = facades.Config().GetString("http_result.Message") } + //查询的结果有可能存在data为nil的情况,判断如果是nil则,给定一个[]string{}类型的数据,避免前端页面报错 + if data == nil { + data = []string{} + } return h.Context.Response().Success().Json(http.Json{ "message": message, "data": data,