once
한 번만 실행
<button v-on:click.once="testFunction">한 번만 호출</button>사용 예제 - once 유뮤에 따른 이벤트 차이
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vue event</title>
</head>
<body>
<div id="app">
<button v-on:click="testFunction">계속 호출</button>
<button v-on:click.once="testFunction">한 번만 호출</button>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script>
const app = Vue.createApp({
methods: {
testFunction() {
window.alert("testFunction 실행");
}
}
});
app.mount("#app");
</script>
</body>
</html>Last updated