質問編集履歴

3

修正

2022/02/24 03:52

投稿

mee12
mee12

スコア101

test CHANGED
File without changes
test CHANGED
@@ -31,13 +31,16 @@
31
31
  data() {
32
32
  return {
33
33
  // 取得できなかった
34
- // id: this.props[0]
34
+ id: this.propsId
35
35
  }
36
36
  },
37
37
 
38
38
  methods: {
39
39
  initialModal() {
40
+ // 検証用 this.idは失敗している、this.propsIdは1回目は取得失敗、2回目は取得される
40
- // Something
41
+ const id1 = this.id;
42
+ const id2 = this.propsId;
43
+
41
44
  console.log("ok");
42
45
  },
43
46
  }
@@ -56,9 +59,9 @@
56
59
 
57
60
  methods: {
58
61
  testAction() {
59
- // ボタ実行時に動的に渡す
62
+ // 検証用にラダムの整数文字 1~10
60
- this.propsId = "1";
63
+ this.propsId = Math.floor(Math.random() * 10).toString();
61
-
64
+
62
65
  this.$refs.child1.initialModal();
63
66
  }
64
67
  }

2

修正

2022/02/24 02:13

投稿

mee12
mee12

スコア101

test CHANGED
File without changes
test CHANGED
@@ -26,14 +26,12 @@
26
26
  const modalComponent = {
27
27
  template: "#modal-component-id",
28
28
 
29
- // どちらが正しいかよくわからなかった
30
- props: [ "props-Id", "propsId" ],
29
+ props: [ "propsId" ],
31
30
 
32
31
  data() {
33
32
  return {
34
- // どちらも取得できなかった
33
+ // 取得できなかった
35
- // id1: this.props[0]
34
+ // id: this.props[0]
36
- // id2: this.props[1]
37
35
  }
38
36
  },
39
37
 

1

修正

2022/02/24 02:12

投稿

mee12
mee12

スコア101

test CHANGED
File without changes
test CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  ```html
12
12
  <div id="app">
13
- <button type="button" v-on:click="testAction()">TestAction1</button>
13
+ <button type="button" v-on:click="testAction()">TestAction</button>
14
14
 
15
15
  <modal-component ref="child1" v-bind:props-id="{ propsId }"></modal-component>
16
16
  </div>