回答編集履歴
3
filtersのmomentメソッド調整
test
CHANGED
@@ -63,3 +63,49 @@
|
|
63
63
|
})
|
64
64
|
|
65
65
|
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
12/14追記
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
momentで与えられた時間をフォーマットする
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
filters: {
|
78
|
+
|
79
|
+
moment: function (date) {
|
80
|
+
|
81
|
+
const today = new Date()
|
82
|
+
|
83
|
+
const time = date.split(':');
|
84
|
+
|
85
|
+
const seconds = time[2].split(' ')[0]
|
86
|
+
|
87
|
+
const timeObj = {
|
88
|
+
|
89
|
+
years: today.getFullYear(),
|
90
|
+
|
91
|
+
months: today.getMonth(),
|
92
|
+
|
93
|
+
days: today.getDay(),
|
94
|
+
|
95
|
+
hours: time[0],
|
96
|
+
|
97
|
+
minutes: time[1],
|
98
|
+
|
99
|
+
seconds: seconds
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
const formattedTime = moment(timeObj).format('YYYY/MM/DD HH:mm:ss')
|
104
|
+
|
105
|
+
return formattedTime
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
```
|
2
dataのusers: []をuserに変更
test
CHANGED
@@ -28,6 +28,20 @@
|
|
28
28
|
|
29
29
|
</template>
|
30
30
|
|
31
|
+
export default {
|
32
|
+
|
33
|
+
data() {
|
34
|
+
|
35
|
+
return {
|
36
|
+
|
37
|
+
user: null,
|
38
|
+
|
39
|
+
};
|
40
|
+
|
41
|
+
},
|
42
|
+
|
43
|
+
}
|
44
|
+
|
31
45
|
|
32
46
|
|
33
47
|
```
|
1
apiの返り値がオブジェクトだと想定した場合の処理に変更
test
CHANGED
@@ -22,11 +22,7 @@
|
|
22
22
|
|
23
23
|
<button v-on:click="call_api()">表示する</button>
|
24
24
|
|
25
|
-
<div v-for="user in users" :key="user.id">
|
26
|
-
|
27
|
-
<span><b>リスト:{{ user| moment }} </b></span>
|
25
|
+
<span><b>リスト:{{ user| moment }} </b></span>
|
28
|
-
|
29
|
-
</div>
|
30
26
|
|
31
27
|
</div>
|
32
28
|
|
@@ -40,13 +36,15 @@
|
|
40
36
|
|
41
37
|
```js
|
42
38
|
|
39
|
+
|
40
|
+
|
43
|
-
// api取得時に整形してthis.user
|
41
|
+
// api取得時に整形してthis.user入れます
|
44
42
|
|
45
43
|
.then(response => {
|
46
44
|
|
47
|
-
const user
|
45
|
+
const user = response.data.results.list1
|
48
46
|
|
49
|
-
this.user
|
47
|
+
this.user = user
|
50
48
|
|
51
49
|
})
|
52
50
|
|