This repository was archived by the owner on Feb 15, 2024. It is now read-only.
File tree 2 files changed +31
-32
lines changed
2 files changed +31
-32
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export default {
36
36
</div >
37
37
<div id =" 'app" ></div >
38
38
<Todo />
39
-
39
+ < test />
40
40
</div >
41
41
</template >
42
42
<style scoped>
Original file line number Diff line number Diff line change 1
1
<script >
2
+ import axios from " axios" ;
2
3
export default {
3
- data (){
4
- return {
5
- newTask: ' ' ,
6
- tasks: [],
7
- };
4
+ name: " App" ,
5
+ data ()
6
+ {
7
+ return {
8
+ data: null ,
9
+ numberOfColumns: 2 ,
10
+ };
11
+ },
12
+ methods: {
13
+ fetchData (){
14
+ axios .get (' https://jsonplaceholder.typicode.com/todos' ).then (response => {this .data = response .data }).catch (error => {console .error (' Error fetching data' ,error);
15
+ });
8
16
},
9
- methods: {
10
- addTask (){
11
- if (this .newTask .trim ()!== ' ' ){
12
- this .tasks .push (this .newTask .trim ());
13
- this .newTask = ' ' ;
14
- }
15
- },
16
- removeTask (index ){
17
- this .tasks .splice (index,1 );
18
- },
19
- },
20
-
17
+ },
21
18
};
22
19
</script >
23
20
24
21
<template >
25
22
<div >
26
- <div >
27
- <p >Message is: {{ message }}</p >
28
- <input v-model =" message" placeholder =" edit me" />
29
- </div >
30
- <div >
31
- <input v-model =" newTask" @key.enter =" addTask" placeholder =" Add a new Task" >
32
- <button @click =" addTask" >Add</button >
33
- </div >
34
- <ul >
35
- <li v-for =" (task,index) in tasks " :key =" index" >
36
- {{ task }}
37
- <button @click =" removeTask(index)" >Remove</button >
38
- </li >
39
- </ul >
23
+
24
+ <button @click =" fetchData" >FetchData</button >
25
+ <table v-if =" data" >
26
+ <thead >
27
+ <tr >
28
+ <th >ID</th >
29
+ <th >title</th >
30
+ </tr >
31
+ </thead >
32
+ <tbody >
33
+ <tr v-for =" item in data" :key =" item.id" >
34
+ <td >{{ item.id }}</td >
35
+ <td :colspan =" 5" >{{ item.title }}</td >
36
+ </tr >
37
+ </tbody >
38
+ </table >
40
39
</div >
41
40
</template >
You can’t perform that action at this time.
0 commit comments