Vue条件语句
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title>條件語句</title><script src="js/vue.js"></script></head><body><div id="app"><!-- v-if --><p v-if="seen">現在你看到我了</p><template v-if="ok"><h1>菜鳥教程</h1><p>學的不僅是技術</p></template><!-- v-else --><div v-if="Math.random() > 0.5"></div>sorry<div v-else>yes</div><!-- v-else-if --><div v-if="type === 'A'">A</div><div v-else-if="type === 'B'">B</div><div v-else-if="type === 'C'">C</div><div v-else="type === 'A'">not a\b\c</div><!-- v-show --><h1 v-show="ok">htllo</h1></div></body><script>new Vue({el: '#app',data: {seen: true,ok: true,type:'C'}})</script>
</html>
總結