你可以通过 forEach 来做到这一点。<div id="generate-h1"></div>var fruits = ["bannanna", "apple", "orange", "grapes"]// Create any HTML Element to put H1 Tags into this HTML Tagvar main = document.createElement('main');// Create H1 items for each fruits// Append it to the main Tag or whatever you have.fruits.forEach(function (fruits) { var headline = document.createElement('h1'); headline.textContent = fruits; main.appendChild(headline);});// Inject into the DOMvar app = document.querySelector('#generate-h1');app.appendChild(main);