본문 바로가기
study/Vue

[Vue] 28. 이벤트 처리하기 (vueex2.html )

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

vueex2.html

<!DOCTYPE html>
<!-- 
	/vue1/src/main/webapp/20220531/vueex2.html 
	예금은 음수값을 인정할 수 없음. 잔고만큼만 인출이 가능해야함. 
-->
<html>
<head>
<meta charset="UTF-8">
<title>이벤트 처리하기</title>
<script type="text/javascript" src="https:unpkg.com/vue@2.5.16/dist/vue.js"></script>
</head>
<body>
<div id="simple">
	<p>
		<input type="text" v-model="amount" >
	</p>
	<p>
	<!-- @click : click 이벤트 발생시. onclick. v-on : click와 같은 의미 -->
		<button id="deposit" v-on:click="balance += parseInt(amount)">예금</button>
		<button id="withdraw" @click="balance -= parseInt(amount)">인출</button>
	</p>
	<h3>계좌잔고 : {{balance}}</h3>
</div>
<script>
	let model = {amount:0, balance:0}
	let simple = new Vue ({
		el : "#simple",
		data : model
	})
</script>
</body>
</html>
728x90
반응형