VueJS - 还在文本区域的开头和结尾提交换行符

VueJS - also submit line breaks at the beginning and end of a textarea

我在 VueJS 组件中使用 axios 来提交与 v-model 绑定的文本区域。

<textarea placeholder="Insert text here" v-model="body"></textarea>

这工作正常(没有点):

Sample text

.

After the line break

提交到我的 PHP-Controller 后的输出是:

Sample text/n

/n

After the line break

开头和结尾有换行符:

.

Sample text

.

After the line break

.

以上示例应具有以下输出:

/n

Sample text/n

/n

After the line break/n

/n

但是开头和结尾的换行符被忽略了

是否也可以提交这些文件?

我找到了解决方案。我实际上应该提到我正在使用 Laravel 框架,它 trim 使用中间件自动处理所有传入的请求字符串。

注释掉

\App\Http\Middleware\TrimStrings::class

Kernel.php 中我禁用了自动 trim。现在我有了我想要的换行符。