次のような動的オプションをSweetAlert2の入力タイプの選択に追加したいと考えています。
swal({
title: 'Select Ukraine',
input: 'select',
inputOptions: {
'SRB': 'Serbia',
'UKR': 'Ukraine',
'HRV': 'Croatia'
},
inputPlaceholder: 'Select country',
showCancelButton: true,
inputValidator: function(value) {
return new Promise(function(resolve, reject) {
if (value === 'UKR') {
resolve();
} else {
reject('You need to select Ukraine :)');
}
});
}
}).then(function(result) {
swal({
type: 'success',
html: 'You selected: ' + result
});
})
これら 3 つの国の代わりに、オブジェクトに保存されている独自のオプションを追加したいと考えています。javascriptを使用してそれを行うにはどうすればよいですか?