Cuando actualizo la página, tengo las preguntas desordenadas. ¿Me pueden ayudar, por favor?
Estos son archivos mst, cuando actualizo la página, a veces obtengo los primeros pasos, pero algunas veces actualizo las páginas. Puedo tener el paso 2 o el paso 5, los archivos vienen desordenados y quiero que los archivos se devuelvan en orden cuando actualizo el página.
init() { const list = []; const $this = this; const $files = [ '/assets/js/template/steps/step_1.mst', '/assets/js/template/steps/step_2.mst', '/assets/js/template/steps/step_3.mst', '/assets/js/template/steps/step_4.mst', '/assets/js/template/steps/step_5.mst', '/assets/js/template/steps/step_6.mst', '/assets/js/template/steps/step_7.mst', ]; $this.addLoading(); $files.forEach(function (item) { list.push( fetch(item) .then((response) => response.text()) .then((template) => { Mustache.parse(template); const output = Mustache.render(template, {}); document .querySelector('.js-simulator-form') .insertAdjacentHTML('beforeend', output); // console.log(output); }) .catch((error) => console.log('Unable to get the template: ', error.message) ) .finally(function () { return true; }) ); return true; }); Promise.all(list).finally(function () { $this.run(); }); }, run() { const $this = this; const $form = this.$item;