首页 > 解决方案 > 如何在数据库中保存换行符

问题描述

我正在使用 typeorm 在服务器上使用 nestjs 框架和在客户端使用 vuejs 来管理我的数据库,

在设置中,我必须提供大文本,并且必须\n在数据库中保存换行符(),

我的代码:

vue 文本区域

<b-form-textarea 
       style="white-space: pre-line"
       v-model="projectShortDesc"
       class="mt-2 description-input"></b-form-textarea>

然后我将这些数据发送v-model="projectShortDesc"到我的服务器,

  @Column({
    type: 'varchar',
    length: 150,
    nullable: true
  })
  shortDescription: string;

并像这样保存:

project.shortDescription = descFromVue;
await this.conn.getRepository(Project).save(project);

enter当我输入描述时,有人可以告诉我如何保存在数据库'\ n'中吗?

谢谢你的帮助!

标签: javascripttypescriptvue.jsnestjstypeorm

解决方案


推荐阅读