Код: Выделить всё
Vite App
const app = document.getElementById('app');
const state = new Proxy(
{
currentPage: 1,
},
{
set(obj, key, value) {
if (key === 'currentPage') {
if (value === 1) app.innerHTML = Page1;
if (value === 2) app.innerHTML = Page2;
window.scrollTo(0, 0);
}
obj[key] = value;
return true;
},
}
);
const Stepper = `
Back
Next
`;
const Page1 = `
You're currently on page 1
${Stepper}`;
const Page2 = `
You're currently on page 2
${Stepper}
`;
const setCurrentPage = (page) =>
(state.currentPage = Math.min(2, Math.max(1, page)));
setCurrentPage(state.currentPage);
Попробуйте сами: https://magnificent-horse-ecfe4e .netlify.app/
Есть ли способ это исправить? Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/790 ... ng-to-next
Мобильная версия