Vue: v-text中绑定的多个连续空格无法正常显示

Created on 23 May 2018  ·  5Comments  ·  Source: vuejs/vue

Version

2.5.16

Reproduction link

https://codesandbox.io/s/rl37koz6wo

Steps to reproduce

Indented.vue页面中的属性文本内容有多个空格

What is expected?

连续的空格显示多个

What is actually happening?

连续的只显示了一个

Most helpful comment

你可能需要学习一下html和css的基础知识。MDN

normal
Sequences of whitespace are collapsed. Newline characters in the source are handled the same as other whitespace. Lines are broken as necessary to fill line boxes.

white-space: pre;

All 5 comments

你可能需要学习一下html和css的基础知识。MDN

normal
Sequences of whitespace are collapsed. Newline characters in the source are handled the same as other whitespace. Lines are broken as necessary to fill line boxes.

white-space: pre;

本来多个空格就只显示一个的。。。如果你要要显示多个,可以使用字符  

为什么我就没有想到呢,感谢@troy351

你可能需要学习一下html和css的基础知识。MDN

normal
Sequences of whitespace are collapsed. Newline characters in the source are handled the same as other whitespace. Lines are broken as necessary to fill line boxes.

white-space: pre;

再加上 white-space: pre-line;完美,万分感谢

建议这样用:

<span class="test" v-html="标&nbsp;&nbsp;&nbsp;&nbsp;题"></span>
Was this page helpful?
0 / 5 - 0 ratings