26
rated 0 times
[
31]
[
5]
/ answers: 1 / hits: 16030
/ 9 Years ago, fri, november 27, 2015, 12:00:00
I can't seem to get v-show
and v-else
to work. The documentation says:
The
v-else
element must following immediately after thev-if
orv-show
element - otherwise it will not be recognized.
Documentation: http://vuejs.org/guide/conditional.html#v-show
Fiddle: https://jsfiddle.net/p2ycjk26/2/
Html:
<table>
<thead>
<tr>
<th>Heading</th>
</tr>
</thead>
<tbody>
<tr v-for="test in tests" v-show="tests.length">
<td>{{ test.name }}</td>
</tr>
<tr v-else>
<td>No data available in table</td>
</tr>
</tbody>
</table>
JavaScript:
new Vue({
el: 'table',
data: {
tests: [{
name: 'Testing'
}, {
name: 'Testing 2'
}, {
name: 'Testing 3'
}]
}
});
It's probably something simple but I can't quite figure it out?
More From » vue.js