teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

formatDateを使っているソースを公開しました。

2020/06/18 11:18

投稿

Tikka123456
Tikka123456

スコア34

title CHANGED
File without changes
body CHANGED
@@ -13,9 +13,84 @@
13
13
  というエラーが出てしまいます。
14
14
  恐らくショボいミスなのでしょうが、ご享受お願いします。
15
15
 
16
+ **Home.vue**
17
+ ```Vue
18
+ <template>
19
+ <div class="home">
20
+ <h2 class="title is-3">taitoru</h2>
21
+ <hr>
22
+ <Item class="item" v-for="post in posts" :key="post.id" :post="post"></Item>
23
+ </div>
16
24
 
25
+ </template>
17
26
 
27
+ <script>
28
+ import Item from '@/components/Item'
29
+ import { db } from '@/main'
18
30
 
31
+ export default {
32
+ name: 'Home',
33
+ components: {
34
+ Item
35
+ },
36
+ data() {
37
+ return {
38
+ posts: []
39
+ }
40
+ },
41
+ firestore() {
42
+ return {
43
+ posts: db.collection('posts')
44
+ }
45
+ }
46
+ }
47
+ </script>
48
+
49
+ ```
50
+
51
+ Item.Vue
52
+ ```Vue
53
+ <template>
54
+ <article class="message">
55
+ <div class="message-header">
56
+ <h2>{{ post.title }}</h2>
57
+ </div>
58
+
59
+ <div class="content">
60
+ <figure class="image is-10x10">
61
+ <div class="is-rounded" :style=" 'background-image: url(' + user.photoURL + ')' "></div>
62
+ </figure>
63
+ <p>{{ user.displayName }}</p>
64
+ <div class="createAt">
65
+ <p>{{ post.createdAt }}</p>
66
+ </div>
67
+ </div>
68
+ </div>
69
+
70
+
71
+ </article>
72
+ </template>
73
+
74
+ <script>
75
+ import { db } from '@/main'
76
+ export default {
77
+ props: ['post'],
78
+ data() {
79
+ return {
80
+ user: {}
81
+ }
82
+ },
83
+ firestore() {
84
+ return {
85
+ user: db.collection('users').doc(this.$props.post.uid)
86
+ }
87
+ }
88
+ }
89
+ </script>
90
+
91
+ ```
92
+
93
+
19
94
  ```ここに言語を入力
20
95
  <template>
21
96
    中略

1

scriptの部分を全文公開しました

2020/06/18 11:18

投稿

Tikka123456
Tikka123456

スコア34

title CHANGED
File without changes
body CHANGED
@@ -24,10 +24,34 @@
24
24
  </template>
25
25
 
26
26
  <script>
27
+ import firebase from 'firebase';
28
+ import { auth } from '@/main'
29
+ import { db } from '@/main'
30
+ export default {
31
+ data() {
32
+ return {
33
+ title: '',
34
+ tags: [],
35
+ content: '',
36
+ tag: '',
37
+ currentUser: {}
38
+ }
27
-   中略
39
+ },
40
+ created() {
41
+ auth.onAuthStateChanged(user => {
42
+ this.currentUser = user
43
+ })
44
+ },
28
- methods: {
45
+ methods: {
46
+ addTag() {
47
+ this.tags.push(this.tag),
48
+ this.tag = ''
49
+ },
50
+ removeTag(idx) {
51
+ this.tags.splice(idx,1)
52
+ },
29
- publish() {
53
+ publish() {
30
- const date = this.$date(new Date(), "DD MMMM, YYYY") //ここの書き方がおかしいと思う
54
+ const date = this.$date(new Date(), "dd MMMM, yyyy")
31
55
  db.collection('posts').add({
32
56
  title: this.title,
33
57
  tags: this.tags,
@@ -40,7 +64,7 @@
40
64
  alert('The post got published!')
41
65
  )
42
66
  }
67
+ }
43
68
  }
44
-
45
69
  </script>
46
70
  ```