回答編集履歴
1
追記
test
CHANGED
@@ -33,3 +33,127 @@
|
|
33
33
|
```
|
34
34
|
|
35
35
|
こんな感じにしてみるとか、`createdAt`だけコメントにしてエラーでないか確認するとかしてみたらいかがでしょう。
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
---
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
やってみた
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
```vue
|
52
|
+
|
53
|
+
<template>
|
54
|
+
|
55
|
+
<div>
|
56
|
+
|
57
|
+
<button type="is-primary" @click="publish" expanded>投稿する</button>
|
58
|
+
|
59
|
+
</div>
|
60
|
+
|
61
|
+
</template>
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
<style scoped>
|
66
|
+
|
67
|
+
</style>
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
<script>
|
72
|
+
|
73
|
+
import firebase from 'firebase'
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
// Initialize Firebase
|
78
|
+
|
79
|
+
firebase.initializeApp({
|
80
|
+
|
81
|
+
適切なやつ
|
82
|
+
|
83
|
+
});
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
export default {
|
88
|
+
|
89
|
+
data () {
|
90
|
+
|
91
|
+
return {
|
92
|
+
|
93
|
+
title: 'title',
|
94
|
+
|
95
|
+
tags: 'tags',
|
96
|
+
|
97
|
+
content: 'content',
|
98
|
+
|
99
|
+
uid: 'uid',
|
100
|
+
|
101
|
+
admin: null
|
102
|
+
|
103
|
+
};
|
104
|
+
|
105
|
+
},
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
methods: {
|
110
|
+
|
111
|
+
publish () {
|
112
|
+
|
113
|
+
const date = this.$date(new Date(), 'dd MMMM, yyyy');
|
114
|
+
|
115
|
+
let db = firebase.firestore();
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
db.collection('posts').add({
|
120
|
+
|
121
|
+
title: this.title,
|
122
|
+
|
123
|
+
tags: this.tags,
|
124
|
+
|
125
|
+
content: this.content,
|
126
|
+
|
127
|
+
createdAt: date,
|
128
|
+
|
129
|
+
uid: this.uid
|
130
|
+
|
131
|
+
})
|
132
|
+
|
133
|
+
.then((post) =>
|
134
|
+
|
135
|
+
// this.$router.push('/post/' + this.post.uid + '/' + this.post.id),
|
136
|
+
|
137
|
+
alert('The post got published!' + post)
|
138
|
+
|
139
|
+
)
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
},
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
created () {
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
};
|
152
|
+
|
153
|
+
</script>
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
でできちゃいましたね…`formatDate`をソースで使ってる所あるか調べるほうがいいのかな…
|