「Vue.js」v-elseディレクティブを使うサンプル
構文
<div v-if="条件式">aa</div>
<div v-else> bb</div>
使用例
<div id="arkgame">
<div v-if="Math.random() > 0.8">
random result condition
</div>
<div v-else>
not condition
</div>
</div>
<script src="vue/2.2.2/vue.min.js"></script>
<script>
new Vue({
el: '#arkgame'
})
</script>
<div id="arkgame">
<div v-if="Math.random() > 0.8">
random result condition
</div>
<div v-else>
not condition
</div>
</div>
<script src="vue/2.2.2/vue.min.js"></script>
<script>
new Vue({
el: '#arkgame'
})
</script>
<div id="arkgame"> <div v-if="Math.random() > 0.8"> random result condition </div> <div v-else> not condition </div> </div> <script src="vue/2.2.2/vue.min.js"></script> <script> new Vue({ el: '#arkgame' }) </script>