1
を選択するために、動的なオプションを追加することが次のようになります選択:代わりに、私は内に保存されている自分のオプションを追加したいものを3カ国のSweetAlert2は、私が<a href="https://sweetalert2.github.io/" rel="nofollow noreferrer">SweetAlert2</a>入力タイプに動的なオプションを追加したい入力
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
});
})
オブジェクト。どうすればjavascriptを使ってそれを行うことができますか?
「動的オプション」とはどういう意味ですか? –
@Andrei Zamfir: "オブジェクトに保存された自分のオプション"は、var savedObject = {'value_1': 'name_1'、 'value_2': 'name_2'、 'value_3': 'name_3'} 'ではない ? –
ええ、それは私が意味するものです –