回答編集履歴

1

回答に仕様が追加されたので編集

2019/02/07 05:22

投稿

rururu3
rururu3

スコア5545

test CHANGED
@@ -1,6 +1,6 @@
1
- jsonデータ取得し、値セットて表示させるまなら
1
+ 処理を考えいところすが
2
2
 
3
-
3
+ とりあえずこんな感じなのかと
4
4
 
5
5
 
6
6
 
@@ -10,33 +10,15 @@
10
10
 
11
11
  <section class="container">
12
12
 
13
- <p v-if="id.id01">this is id01</p>
13
+ <p>{{ message }}</p>
14
14
 
15
- <p v-if="id.id02">this is id02</p>
16
-
17
- <p v-if="id.id03">this is id03</p>
18
-
19
- <p v-if="id.id04">this is id04</p>
20
-
21
- <p v-if="id.id05">this is id05</p>
22
-
23
- <p v-if="id.id06">this is id06</p>
24
-
25
- <p v-if="id.id07">this is id07</p>
26
-
27
- <p v-if="id.id08">this is id08</p>
28
-
29
- <p v-if="id.id09">this is id09</p>
30
-
31
- <p v-if="id.id10">this is id10</p>
32
-
33
- <div class="btn-wrapper">
15
+ <div class="btn-wrapper" v-if="isButtonVisible">
34
16
 
35
17
  <div class="btn__inner-wrapper">
36
18
 
37
- <button type="button" class="btn-back">戻る</button>
19
+ <button type="button" class="btn-back" v-on:click="backButtonClick()">戻る</button>
38
20
 
39
- <button type="button" class="btn-next">次へ</button>
21
+ <button type="button" class="btn-next" v-on:click="nextButtonClick()">次へ</button>
40
22
 
41
23
  </div>
42
24
 
@@ -60,31 +42,51 @@
60
42
 
61
43
  return {
62
44
 
63
- id: {
45
+ idx: -1,
64
46
 
65
- id01: false,
47
+ list: [
66
48
 
67
- id02: false,
49
+ ],
68
50
 
69
- id03: false,
51
+ };
70
52
 
71
- id04: false,
53
+ },
72
54
 
73
- id05: false,
55
+ computed: {
74
56
 
75
- id06: false,
57
+ message: function() {
76
58
 
77
- id07: false,
59
+ if(this.idx < 0) {
78
60
 
79
- id08: false,
61
+ return('');
80
-
81
- id09: false,
82
-
83
- id10: false
84
62
 
85
63
  }
86
64
 
65
+ return("this is " + this.list[this.idx].key);
66
+
87
- };
67
+ },
68
+
69
+ isButtonVisible: function() {
70
+
71
+ return(this.idx >= 0);
72
+
73
+ },
74
+
75
+ },
76
+
77
+ methods: {
78
+
79
+ backButtonClick: function() {
80
+
81
+ this.idx = (this.idx + this.list.length - 1) % this.list.length;
82
+
83
+ },
84
+
85
+ nextButtonClick: function() {
86
+
87
+ this.idx = (this.idx + 1) % this.list.length;
88
+
89
+ },
88
90
 
89
91
  },
90
92
 
@@ -96,9 +98,19 @@
96
98
 
97
99
  // trueのidのみ取得しオブジェクトを生成
98
100
 
101
+ this.list.slice(0, this.list.length);
102
+
103
+ this.idx = -1;
104
+
99
105
  Object.keys(response.data.id).forEach(key => {
100
106
 
107
+ if(response.data.id[key] != false) {
108
+
101
- this.id[key] = response.data.id[key];
109
+ this.list.push({key: key, value: response.data.id[key]});
110
+
111
+ this.idx = 0;
112
+
113
+ }
102
114
 
103
115
  });
104
116