回答編集履歴
1
ボツ案追記
test
CHANGED
@@ -65,3 +65,85 @@
|
|
65
65
|
</script>
|
66
66
|
|
67
67
|
```
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
ちなみに最初に考えた下記のコードだと、1行ごとに色が切り替わりませんでした。(3行まとめて色が変わる)
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
// 下記はボツ案。3行まとめて色が変わってしまう。
|
76
|
+
|
77
|
+
<style>
|
78
|
+
|
79
|
+
.hover {
|
80
|
+
|
81
|
+
color: red;
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
</style>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<div id="app">
|
90
|
+
|
91
|
+
<h2>My Traffic Route</h2>
|
92
|
+
|
93
|
+
<h3>出発駅:{{ start }} / 到着駅:{{ goal }}</h3>
|
94
|
+
|
95
|
+
<ol>
|
96
|
+
|
97
|
+
<li v-for="route in routes" @mouseover="toggle()" @mouseleave="toggle()" :class="{'hover': hovered}">
|
98
|
+
|
99
|
+
{{ route.getOn }} —({{route.line}})— {{ route.getOff }}
|
100
|
+
|
101
|
+
</li>
|
102
|
+
|
103
|
+
</ol>
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
<script>
|
110
|
+
|
111
|
+
new Vue({
|
112
|
+
|
113
|
+
el: "#app",
|
114
|
+
|
115
|
+
data: {
|
116
|
+
|
117
|
+
start: "大宮",
|
118
|
+
|
119
|
+
goal: "成田",
|
120
|
+
|
121
|
+
routes: [
|
122
|
+
|
123
|
+
{ line: "宇都宮線", getOn:"大宮", getOff: "上野" },
|
124
|
+
|
125
|
+
{ line: "常磐線", getOn:"上野", getOff: "我孫子" },
|
126
|
+
|
127
|
+
{ line: "成田線", getOn:"我孫子", getOff: "成田" }
|
128
|
+
|
129
|
+
],
|
130
|
+
|
131
|
+
hovered: false,
|
132
|
+
|
133
|
+
},
|
134
|
+
|
135
|
+
methods: {
|
136
|
+
|
137
|
+
toggle: function(){
|
138
|
+
|
139
|
+
this.hovered = !this.hovered
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
})
|
146
|
+
|
147
|
+
</script>
|
148
|
+
|
149
|
+
```
|