<!DOCTYPE html>
<html>
<head>
<title>Moose count</title>
<style>
#app {
border: dashed black 1px;
width: 250px;
padding: 10px;
}
img {
width: 100%;
}
button {
margin: 10px;
padding: 5px 10px;
}
</style>
</head>
<body>
<h1>Example: Passing Arguments with Methods</h1>
<div id="app">
<img src="img_moose.jpg" width="770" height="549">
<p>{{ "Moose count: " + count }}</p>
<button v-on:click="addMoose(1)">+1</button>
<button v-on:click="addMoose(5)">+5</button>
<button v-on:click="addMoose(-1)">-1</button>
</div>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
const app = Vue.createApp({
data() {
return {
count: 0
}
},
methods: {
addMoose(number) {
this.count+=number
}
}
})
app.mount('#app')