質問編集履歴
2
formatDateを使っているソースを公開しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,7 +28,157 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
-
|
31
|
+
**Home.vue**
|
32
|
+
|
33
|
+
```Vue
|
34
|
+
|
35
|
+
<template>
|
36
|
+
|
37
|
+
<div class="home">
|
38
|
+
|
39
|
+
<h2 class="title is-3">taitoru</h2>
|
40
|
+
|
41
|
+
<hr>
|
42
|
+
|
43
|
+
<Item class="item" v-for="post in posts" :key="post.id" :post="post"></Item>
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
</template>
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
<script>
|
54
|
+
|
55
|
+
import Item from '@/components/Item'
|
56
|
+
|
57
|
+
import { db } from '@/main'
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
export default {
|
62
|
+
|
63
|
+
name: 'Home',
|
64
|
+
|
65
|
+
components: {
|
66
|
+
|
67
|
+
Item
|
68
|
+
|
69
|
+
},
|
70
|
+
|
71
|
+
data() {
|
72
|
+
|
73
|
+
return {
|
74
|
+
|
75
|
+
posts: []
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
},
|
80
|
+
|
81
|
+
firestore() {
|
82
|
+
|
83
|
+
return {
|
84
|
+
|
85
|
+
posts: db.collection('posts')
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
</script>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
Item.Vue
|
102
|
+
|
103
|
+
```Vue
|
104
|
+
|
105
|
+
<template>
|
106
|
+
|
107
|
+
<article class="message">
|
108
|
+
|
109
|
+
<div class="message-header">
|
110
|
+
|
111
|
+
<h2>{{ post.title }}</h2>
|
112
|
+
|
113
|
+
</div>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
<div class="content">
|
118
|
+
|
119
|
+
<figure class="image is-10x10">
|
120
|
+
|
121
|
+
<div class="is-rounded" :style=" 'background-image: url(' + user.photoURL + ')' "></div>
|
122
|
+
|
123
|
+
</figure>
|
124
|
+
|
125
|
+
<p>{{ user.displayName }}</p>
|
126
|
+
|
127
|
+
<div class="createAt">
|
128
|
+
|
129
|
+
<p>{{ post.createdAt }}</p>
|
130
|
+
|
131
|
+
</div>
|
132
|
+
|
133
|
+
</div>
|
134
|
+
|
135
|
+
</div>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
</article>
|
142
|
+
|
143
|
+
</template>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
<script>
|
148
|
+
|
149
|
+
import { db } from '@/main'
|
150
|
+
|
151
|
+
export default {
|
152
|
+
|
153
|
+
props: ['post'],
|
154
|
+
|
155
|
+
data() {
|
156
|
+
|
157
|
+
return {
|
158
|
+
|
159
|
+
user: {}
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
},
|
164
|
+
|
165
|
+
firestore() {
|
166
|
+
|
167
|
+
return {
|
168
|
+
|
169
|
+
user: db.collection('users').doc(this.$props.post.uid)
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
</script>
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
```
|
32
182
|
|
33
183
|
|
34
184
|
|
1
scriptの部分を全文公開しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -50,13 +50,61 @@
|
|
50
50
|
|
51
51
|
<script>
|
52
52
|
|
53
|
-
|
53
|
+
import firebase from 'firebase';
|
54
54
|
|
55
|
-
m
|
55
|
+
import { auth } from '@/main'
|
56
56
|
|
57
|
-
|
57
|
+
import { db } from '@/main'
|
58
58
|
|
59
|
+
export default {
|
60
|
+
|
61
|
+
data() {
|
62
|
+
|
63
|
+
return {
|
64
|
+
|
65
|
+
title: '',
|
66
|
+
|
67
|
+
tags: [],
|
68
|
+
|
69
|
+
content: '',
|
70
|
+
|
71
|
+
tag: '',
|
72
|
+
|
73
|
+
currentUser: {}
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
},
|
78
|
+
|
79
|
+
created() {
|
80
|
+
|
81
|
+
auth.onAuthStateChanged(user => {
|
82
|
+
|
83
|
+
this.currentUser = user
|
84
|
+
|
85
|
+
})
|
86
|
+
|
87
|
+
},
|
88
|
+
|
89
|
+
methods: {
|
90
|
+
|
91
|
+
addTag() {
|
92
|
+
|
93
|
+
this.tags.push(this.tag),
|
94
|
+
|
95
|
+
this.tag = ''
|
96
|
+
|
97
|
+
},
|
98
|
+
|
99
|
+
removeTag(idx) {
|
100
|
+
|
101
|
+
this.tags.splice(idx,1)
|
102
|
+
|
103
|
+
},
|
104
|
+
|
105
|
+
publish() {
|
106
|
+
|
59
|
-
const date = this.$date(new Date(), "
|
107
|
+
const date = this.$date(new Date(), "dd MMMM, yyyy")
|
60
108
|
|
61
109
|
db.collection('posts').add({
|
62
110
|
|
@@ -82,9 +130,9 @@
|
|
82
130
|
|
83
131
|
}
|
84
132
|
|
133
|
+
}
|
134
|
+
|
85
135
|
}
|
86
|
-
|
87
|
-
|
88
136
|
|
89
137
|
</script>
|
90
138
|
|