Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. <template>
  2. <div id="app">
  3. <h4 class="bg-primary text-white text-center p-2">
  4. {{name}}'s To Do List
  5. </h4>
  6. <div class="container-fluid p-4">
  7. <div class="row" v-if="filteredTasks.length == 0">
  8. <div class="col text-center">
  9. <b>Nothing to do!</b>
  10. </div>
  11. </div>
  12. <template v-else>
  13. <div class="row">
  14. <div class="col font-weight-bold">Task</div>
  15. <div class="col-2 font-weight-bold">Done</div>
  16. </div>
  17. <div class="row" v-for="t in filterTasks" v-bind:key="t.action">
  18. <div class="col">{{t.action}}</div>
  19. <div class="col-2" text-center>
  20. <input type="checkbox" v-model="t.done" class="form-check-input" />
  21. {{t.done}}</div>
  22. </div>
  23. </template>
  24. <div class="row py-2">
  25. <div class="col">
  26. <input v-model="newItemText" class="form-control" />
  27. </div>
  28. <div class="col-2">
  29. <button class="btn btn-primary" v-on:click="addNewTodo">Add</button>
  30. </div>
  31. </div>
  32. <div class="row bg-secondary py-2 nt-2 text-white">
  33. <div class="col text-center">
  34. <input type="checkbox" v-model="hideCompleted" class="form-check-input" />
  35. <label class="form-check-label font-weight-bold">
  36. Hide Completed tasks
  37. </label>
  38. </div>
  39. <div> class="col text-center">
  40. <button class="btn btn-sn btn-warning" v-on:click="deleteComplete">
  41. Delete Completed
  42. </button>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. </template>
  48.  
  49. <script>
  50.  
  51. export default {
  52. name: 'app',
  53. data(){
  54. return{
  55. name: "Derek",
  56. tasks:[],
  57. hideCompleted: true,
  58. newItemText: ""
  59. }
  60. },
  61. computed: {
  62. filterTasks() {
  63. return this.hideCompleted ?
  64. this.tasks.filter(t => !t.done) : this.tasks
  65. }
  66. },
  67. methods: {
  68. addNewTodo() {
  69. this.tasks.push({
  70. action: this.newItemText,
  71. done: false
  72. });
  73. this.storeData();
  74. this.newItemText="";
  75. }
  76. },
  77. storeData() {
  78. localStorage.setItem("todos", JSON.stringify(this.tasks));
  79. },
  80. deleteComplete() {
  81. this.tasks = this.tasks.filter(t => !t.done);
  82. this.storeData();
  83. },
  84. created() {
  85. let data = localStorage.getItem("todos");
  86. if (data != null){
  87. this.tasks = JSON.parse(data);
  88. }
  89. }
  90. }
  91. </script>
  92.  
  93. <style>
  94. #app {
  95. font-family: 'Avenir', Helvetica, Arial, sans-serif;
  96. -webkit-font-smoothing: antialiased;
  97. -moz-osx-font-smoothing: grayscale;
  98. text-align: center;
  99. color: #2c3e50;
  100. margin-top: 60px;
  101. }
  102. </style>
  103.  
  104.  
  105. import Vue from 'vue'
  106. //import App from './App_final.vue'
  107. import App from './App8.vue'
  108.  
  109. Vue.config.productionTip = false
  110.  
  111. //import "bootstrap/dist/css/boostrap.min.css";
  112.  
  113. new Vue({
  114. render: h => h(App),
  115. }).$mount('#app')
  116.  
  117. <template>
  118. <div id="app">
  119. <h4 class="bg-primary text-white text-center p-2">
  120. {{name}}'s To Do List
  121. </h4>
  122. <div class="container-fluid p-4">
  123. <div class="row">
  124. <div class="col font-weight-bold">Task</div>
  125. <div class="col-2 font-weight-bold">Done</div>
  126. </div>
  127. <div class="row" v-for="t in filterTasks" v-bind:key="t.action">
  128. <div class="col">{{t.action}}</div>
  129. <div class="col-2" text-center>
  130. <input type="checkbox" v-model="t.done" class="form-check-input" />
  131. {{t.done}}</div>
  132. </div>
  133. <div class="row py-2">
  134. <div class="col">
  135. <input v-model="newItemText" class="form-control" />
  136. </div>
  137. <div class="col-2">
  138. <button class="btn btn-primary" v-on:click="addNewTodo">Add</button>
  139. </div>
  140. </div>
  141. <div class="row bg-secondary py-2 nt-2 text-white">
  142. <div class="col text-center">
  143. <input type="checkbox" v-model="hideCompleted" class="form-check-input" />
  144. <label class="form-check-label font-weight-bold">
  145. Hide Completed tasks
  146. </label>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. </template>
  152.  
  153. <script>
  154.  
  155. export default {
  156. name: 'app',
  157. data(){
  158. return{
  159. name: "Derek",
  160. tasks:[],
  161. hideCompleted: true,
  162. newItemText: ""
  163. }
  164. },
  165. computed: {
  166. filterTasks() {
  167. return this.hideCompleted ?
  168. this.tasks.filter(t => !t.done) : this.tasks
  169. }
  170. },
  171. methods: {
  172. addNewTodo() {
  173. this.tasks.push({
  174. action: this.newItemText,
  175. done: false
  176. });
  177. localStorage.setItem("todos", JSON.stringify(this.tasks));
  178. this.newItemText="";
  179. }
  180. },
  181. created() {
  182. let data = localStorage.getItem("todos");
  183. if (data != null){
  184. this.tasks = JSON.parse(data);
  185. }
  186. }
  187. }
  188. </script>
  189.  
  190. <style>
  191. #app {
  192. font-family: 'Avenir', Helvetica, Arial, sans-serif;
  193. -webkit-font-smoothing: antialiased;
  194. -moz-osx-font-smoothing: grayscale;
  195. text-align: center;
  196. color: #2c3e50;
  197. margin-top: 60px;
  198. }
  199. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement