Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Final Improvements and Cleanup | Section
Практика
Проекти
Вікторини та виклики
Вікторини
Виклики
/
Vue.js Fundamentals and App Development

bookFinal Improvements and Cleanup

Свайпніть щоб показати меню

At this stage, the application is working, but you can improve the user experience and code structure.

Start by improving the UI feedback. For example, show a message when there are no tasks.

<template>
  <ul v-if="tasks.length > 0">
    <li v-for="task in tasks" :key="task.id">
      {{ task.text }}
    </li>
  </ul>
  <p v-else>No tasks yet</p>
</template>

Next, improve the visual state of completed tasks.

<template>
  <li
    v-for="task in tasks"
    :key="task.id"
    @click="toggleTask(task)"
    :class="{ completed: task.completed }"
  >
    {{ task.text }}
  </li>
</template>

<style>
.completed {
  text-decoration: line-through;
  color: gray;
}
</style>

You can also prevent adding empty tasks by disabling the button.

<template>
  <button @click="addTask" :disabled="newTask === ''">
    Add Task
  </button>
</template>

Finally, review your code and keep it clean and organized:

  • Remove unused variables and code;
  • Keep components simple anU focused;
  • Use clear naming for variables and functions.

These improvements make your application more polished and easier to maintain.

Final Wrap-Up

You've built a complete Vue application by combining components, state, and user interactions. You structured the interface, handled input, and made the app dynamic using reactive data.

You now have the foundation to build your own Vue applications and extend them with new features and improvements.

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 26

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Секція 1. Розділ 26
some-alt