質問編集履歴
2
文章修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
[Message.vue](https://github.com/yoshida-riki/TimeOverGrow-new/blob/master/components/Message.vue)の63行目の```onDelete()```メソッドの挙動の修正です。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
また、フロントはVue.js、バックエンドはFirebaseで実装しております。
|
6
10
|
|
7
11
|
|
8
12
|
|
1
質問の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,6 +16,118 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
+
削除ボタンあたりの挙動を記したコードは下記の通りです。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
=====================================================
|
24
|
+
|
25
|
+
Message.js
|
26
|
+
|
27
|
+
```
|
28
|
+
|
29
|
+
static async clear() {
|
30
|
+
|
31
|
+
const clearId = []
|
32
|
+
|
33
|
+
const uid = firebase.auth().currentUser.uid
|
34
|
+
|
35
|
+
const collection = await dbMessages.where('uid', '==', uid).orderBy('date').get()
|
36
|
+
|
37
|
+
try {
|
38
|
+
|
39
|
+
await collection.forEach(doc => {
|
40
|
+
|
41
|
+
clearId.push(doc.id)
|
42
|
+
|
43
|
+
})
|
44
|
+
|
45
|
+
return clearId
|
46
|
+
|
47
|
+
} catch (error) {
|
48
|
+
|
49
|
+
console.error(error);
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
```
|
56
|
+
|
57
|
+
=======================================================
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
Message.vue
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
~
|
66
|
+
|
67
|
+
<v-btn
|
68
|
+
|
69
|
+
color="success"
|
70
|
+
|
71
|
+
@click="onDelete()"
|
72
|
+
|
73
|
+
>
|
74
|
+
|
75
|
+
<v-icon>mdi-trash-can-outline</v-icon>
|
76
|
+
|
77
|
+
</v-btn>
|
78
|
+
|
79
|
+
~
|
80
|
+
|
81
|
+
methods: {
|
82
|
+
|
83
|
+
async onDelete() {
|
84
|
+
|
85
|
+
try {
|
86
|
+
|
87
|
+
const id = this.i
|
88
|
+
|
89
|
+
const docId = await MessageModel.clear()
|
90
|
+
|
91
|
+
if(docId === []) {
|
92
|
+
|
93
|
+
alert('削除できるデータがありません')
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
await dbMessages.doc(docId[id]).delete()
|
98
|
+
|
99
|
+
// console.log(await MessageModel.dbtime() -
|
100
|
+
|
101
|
+
dbMessages.doc(docId[id]).date())
|
102
|
+
|
103
|
+
console.log(MessageModel.dbtime());
|
104
|
+
|
105
|
+
console.log(docId[id]);
|
106
|
+
|
107
|
+
console.log(docId);
|
108
|
+
|
109
|
+
console.log(id);
|
110
|
+
|
111
|
+
} catch (error) {
|
112
|
+
|
113
|
+
console.error(error)
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
```
|
126
|
+
|
127
|
+
===========================================================
|
128
|
+
|
129
|
+
|
130
|
+
|
19
131
|
原因が分からないでいるのでもし宜しければアドバイス頂きたいです。
|
20
132
|
|
21
133
|
宜しくお願い致します。
|