Код: Выделить всё
// Sample data
const options = [
{ value: '1', text: 'Option 1' },
{ value: '2', text: 'Option 2' },
{ value: '3', text: 'Option 3' },
];
// Get the select element
const select = document.getElementById('items');
// Populate the select with options
options.forEach(option => {
const opt = document.createElement('option'); // Create a new element
opt.value = option.value; // Set the value attribute
opt.textContent = option.text; // Set the visible text
select.appendChild(opt); // Add the option to the
});
Код: Выделить всё
const options = vm.getData();
Подробнее здесь: https://stackoverflow.com/questions/795 ... data-array
Мобильная версия