如何在select2数据行中的一行中显示多个空格字符? [英] How can I show more than one white space character in a row in a select2 data row?
本文介绍了如何在select2数据行中的一行中显示多个空格字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Select2 ,并且我使用{data: [{id:1, text: "..."}]
方法来定义选项.我想通过将使用多个空格字符组成的子字符串分组来格式化每个选项.像这样:
I'm using Select2 and I use the {data: [{id:1, text: "..."}]
approach to define the options. I want to format each option by grouping the substring it's made up of using more than one white space character. So something like this:
{data: [
{id:1, text: "Trees - Oak"},
{id:2, text: "Trees - Pine"},
{id:3, text: "Seas - North Sea"},
{id:4, text: "Seas - Baltic Sea"}
]}
当我这样做时,它们在结果下拉列表中显示为一个空格(处理空格的默认HTML方式).当我使用
代替空格时,它们在下拉列表中显示为字符串"
"而不是空格.
When I do this they show up as one space in the resulting dropdown (the default HTML way of dealing with spaces). When I use
instead of space they show up as the string "
" in the dropdown instead of as spaces.
{data: [
{id:1, text: "Trees - Oak"},
{id:2, text: "Trees - Pine"},
{id:3, text: "Seas - North Sea"},
{id:4, text: "Seas - Baltic Sea"}
]}
是否可以保留我在数据项的text
属性中定义的所有空间?
Is there a way to preserve all the spaces I define in the text
attribute of the data item?
推荐答案
查看全文