配置

要在初始化Select2时配置自定义选项,只需在调用中将一个对象传递给.select2():

$('.js-example-basic-single').select2({
  placeholder: 'Select an option'
});