본문 바로가기
study/Vue

[Vue] 28. v-if : 조건 디렉티브 (vueex3.html )

by 금이패런츠 2022. 5. 30.
728x90
반응형

vueex3.html 

<!DOCTYPE html>
<!-- /vue1/src/main/webapp/20220530/vueex3.html -->
<html>
<head>
<meta charset="UTF-8">
<title>v-if : 조건 디렉티브</title>
<script type="text/javascript" src="https:unpkg.com/vue@2.5.16/dist/vue.js"></script>
</head>
<body>
<div id="account">
	<!-- v-model : 입력된 값을 amount 데이터에 저장 -->
	예금액 : <input type="text" v-model="amount" >
	<!-- 
		v-show : amount < 0 결과가 True인 경우 img를 보여줌. 이미지를 로드하고, 결과가 True인 경우만 보여줌.
		v-if   : amount < 0 결과가 True인 경우 img를 로드함.
	 -->
	<img v-show="amount < 0" src="http://sample.bmaster.kro.kr/img/error.png"
	title="마이너스는 허용하지 않습니다." style="width:15px; height:15px; vertical-align:middle" />
	<span v-if="amount >= 1000000">Gold</span>
	<span v-else-if="amount >= 500000">Silver</span>
	<span v-else-if="amount >= 200000">Bronze</span>
	<span v-else>Basic</span>
</div>
<script type="text/javascript">
	let simple = new Vue ({
		el : "#account",
		data : {amount : 0}
	})
</script>
</body>
</html>
728x90
반응형