1. 程式人生 > >Vue入門05--if,else

Vue入門05--if,else

程式碼:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="js/vue.js" ></script>
		<style>
			.show{
				width: 100px;
				height: 100px;
				background: red;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<div class="show" v-if="isShow">
				1
			</div>

			<div v-else>
				2
			</div>
		
		</div>
		<script>
			new Vue({
				el:"#app",
				data:{
					isShow:false
				}
			})
		</script>
	</body>
</html>

顯示:2