From 7c103f01a90f87ec3b31638a8680e258aae2f405 Mon Sep 17 00:00:00 2001 From: aixianling Date: Wed, 1 Mar 2023 17:28:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86JSON.=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/dbUitls.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/dbUitls.js b/src/utils/dbUitls.js index 60094b3..c17070b 100644 --- a/src/utils/dbUitls.js +++ b/src/utils/dbUitls.js @@ -23,7 +23,7 @@ const insert = ({table, form}) => { let sql if (form.id) {//编辑 let arr = Object.keys(form).filter(e => form[e]).map(e => { - if (typeof form[e] == "object") form[e] = JSON.stringify(form[e]) + if (typeof form[e] == "object") form[e] = JSON.stringify(form[e]).replace(/"/g,"'") return `${e}='${form[e]}'` }) sql = `update ${table} set ${arr.join(",")} where id='${form.id}'` @@ -32,7 +32,7 @@ const insert = ({table, form}) => { Object.keys(form).map(e => { if (form[e]) { cols.push(e) - if (typeof form[e] == "object") form[e] = JSON.stringify(form[e]) + if (typeof form[e] == "object") form[e] = JSON.stringify(form[e]).replace(/"/g,"'") arr.push(`'${form[e]}'`) } })