我正在尝试将 Vue 2 组件迁移到 Vue 3。这个想法就像 Vue 的“ln2br”(实际上是“ln2p”)。
所以...
This is the line 1. This is the line 2. This is the line 3.
应该渲染:
This is the line 1.
This is the line 2.
This is the line 3.
这是我的工作组件 MyLinebreaker.vue 的Vue 2代码:
{{ line }}
Slots API 在 Vue 3 中发生了变化,因此我尝试重写我的 lines 计算结果:
但它渲染错误(所有行都在一行中),因为 .children 不包含 \n 字符。
This is the line 1. This is the line 2. This is the line 3.
那么,如何在Vue 3中获取 \n char 的文本内容?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号