我在v4.0.3中使用select2
我想将默认语言从英语更改为西班牙语。查看国际化部分中的文档,但如上所述,它对我没有用。
我很关注您的评论附件
$("#multisearch").select2({
language: "es",
closeOnSelect: false,
placeholder: "Comienza tu búsqueda",
data: [
{
id: 0,
text: 'Linea 1',
children:
[{
id: 1,
text: 'San Pablo'
},
{
id: 2,
text: 'Pajaritos'
},
{
id: 3,
text: 'Las Rejas'
},
{
id: 4,
text: 'Ecuador'
}]
},
{
id: 5,
text: 'Linea 2',
children:
[{
id: 6,
text: 'La Cisterna'
},
{
id: 7,
text: 'El Parrón'
},
{
id: 8,
text: 'Lo Ovalle'
},
{
id: 9,
text: 'Ciudad del niño'
},
{
id: 10,
text: 'Pajaritos'
}
]
},
{ id: 1, text: 'prueba' },
]});
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<select multiple id="multisearch" style="width:500px">
</select>
我会很专心,非常感谢你
答案 0 :(得分:0)
$("#multisearch").select2({ language: "es", closeOnSelect: false, placeholder: "Comienza tu búsqueda", data: [ { id: 0, text: 'Linea 1', children: [{ id: 1, text: 'San Pablo' }, { id: 2, text: 'Pajaritos' }, { id: 3, text: 'Las Rejas' }, { id: 4, text: 'Ecuador' }] }, { id: 5, text: 'Linea 2', children: [{ id: 6, text: 'La Cisterna' }, { id: 7, text: 'El Parrón' }, { id: 8, text: 'Lo Ovalle' }, { id: 9, text: 'Ciudad del niño' }, { id: 10, text: 'Pajaritos' } ] }, { id: 1, text: 'prueba' }, ]});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<select multiple id="multisearch" style="width:500px">
</select>
&#13;