lovelmh13 / myBlog

个人博客 记录菜狗的学习之路
6 stars 0 forks source link

防止 MyCat 吞掉某些字符 #138

Open lovelmh13 opened 3 years ago

lovelmh13 commented 3 years ago
if (process.env.NODE_ENV !== 'development') {
    // 区分线上环境,只有线上环境才有 MyCat
    componentData = componentData
      .replace(/\\n/g, '\\\\n')
      .replace(/\\"/g, '\\\\"')
      .replace(/\\t/g, '\\\\t')
      .replace(/\\b/g, '\\\\b')
      .replace(/\\f/g, '\\\\f')
      .replace(/\\r/g, '\\\\r')
}

一定要在入库的时候,使用 sql 的时候再使用这个方法,不要一上来就用,不然序列化会出问题的!!!!!!!