Guest User

Untitled

a guest
Sep 28th, 2020
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>ToDo List</title>
  5. <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  6. <style type="text/css">
  7. .new-task-input {
  8. width: 300px;
  9. font-size: 24px;
  10. }
  11. .add-task-button {
  12. font-size: 24px;
  13. }
  14. .task-item {
  15. font-size: 24px;
  16. border: 1px solid gray;
  17. margin-top: 10px;
  18. width: 500px;
  19. padding: 5px 10px;
  20. background-color: #dddddd;
  21. }
  22. .task-buttons {
  23. float: right;
  24. display: flex;
  25. align-items: center;
  26. height: 28px;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <h1>Список задач</h1>
  32. <div id="app">
  33. <input class="new-task-input" v-model="newTask" type="text" name="">&nbsp;&nbsp;<button class="add-task-button" v-on:click="addTask()">Добавить</button>
  34.  
  35. <div class="task-item" v-for="task, i in tasks">
  36. {{ task }}
  37. <div class="task-buttons">
  38. <button v-on:click="editTask(i)">Edit</button>
  39. </div>
  40. </div>
  41. </div>
  42.  
  43. <script type="text/javascript">
  44. var app = new Vue({
  45. el: '#app',
  46. data: {
  47. newTask: "",
  48. tasks: ["Первая задача", "Вторая задача", "Третья задача"]
  49. },
  50. methods: {
  51. addTask: function(){
  52. this.tasks.push(this.newTask);
  53. this.newTask = "";
  54. },
  55. editTask: function(i){
  56. let newTask = prompt("Измените задачу:", this.tasks[i]);
  57. Vue.set(this.tasks, i, newTask);
  58. }
  59. }
  60. });
  61. </script>
  62. </body>
  63. </html>
Add Comment
Please, Sign In to add comment