質問編集履歴

1

henkou

2018/12/13 07:45

投稿

tokuwgawa
tokuwgawa

スコア45

test CHANGED
@@ -1 +1 @@
1
- 【Nuxt.js】子コンポーネントのメソッド内のforEachでpropsデータを使用する方法
1
+ henkou【Nuxt.js】子コンポーネントのメソッド内のforEachでpropsデータを使用する方法
test CHANGED
@@ -1,4 +1,6 @@
1
- 子コンポーネント内メソッドの`forEach`で`props`ないのデータを取得したいのですが、`this.template.width`
1
+ 子コンポーネント内メソッドの`forEach`で`props`ないのデータを取得したいのですが、`this.template.width`などをログで吐かせてもundefindになってしまいます。
2
+
3
+ このような時に`forEach`内で`props`の変数を取得する方法を教えてください。
2
4
 
3
5
 
4
6
 
@@ -44,8 +46,6 @@
44
46
 
45
47
  getTemplates() {
46
48
 
47
- // テストデータ
48
-
49
49
  let templates = [
50
50
 
51
51
  {
@@ -86,6 +86,8 @@
86
86
 
87
87
  oldTemplates.forEach(function (templateSettings) {
88
88
 
89
+      //this.template.width と this.template.height が undefind になってしまう
90
+
89
91
  if(templateSettings.width == this.template.width && templateSettings.height == this.template.height) {
90
92
 
91
93
  templates.append(template)