質問編集履歴
1
コードを追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,4 +2,44 @@
|
|
2
2
|
|
3
3
|

|
4
4
|
|
5
|
-
これのcontentを配列で引っ張ってきたいんですがなぜかうまくいきません。。。
|
5
|
+
これのcontentを配列で引っ張ってきたいんですがなぜかうまくいきません。。。
|
6
|
+
nuxtで下記のコードで書いているのですがcreatedで引っ張るところがわかっていません。
|
7
|
+
|
8
|
+
```
|
9
|
+
<template>
|
10
|
+
</template>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
import firebase from '@/plugins/firebase'
|
14
|
+
import { mapState } from 'vuex'
|
15
|
+
|
16
|
+
export default {
|
17
|
+
name: 'mypage',
|
18
|
+
props: ['user'],
|
19
|
+
data (context) {
|
20
|
+
// コンポーネントをロードする前に毎回呼び出されます
|
21
|
+
return { note_content: 'hello', notes:[]}
|
22
|
+
},
|
23
|
+
// DOMが作成されたときに値を代入する
|
24
|
+
created:
|
25
|
+
// ここがうまく書けない。
|
26
|
+
computed: {
|
27
|
+
...mapState({
|
28
|
+
mypageUrl: (state) => `/user/${state.uid}`
|
29
|
+
})
|
30
|
+
},
|
31
|
+
methods: {
|
32
|
+
saveContent: function(value) {
|
33
|
+
// 新しいテキストのためのキーを取得
|
34
|
+
var newNoteKey = firebase.database().ref().child('notes').push().key;
|
35
|
+
var today = Date.now();
|
36
|
+
firebase
|
37
|
+
.database()
|
38
|
+
.ref('notes/' + this.user.uid + '/' + newNoteKey)
|
39
|
+
.set({content:value,date:today});
|
40
|
+
}
|
41
|
+
}
|
42
|
+
/*以下省略*/
|
43
|
+
}
|
44
|
+
</script>
|
45
|
+
```
|