The following bit of code shows how to react to a click event:
- Fill in the following HTML:
<div id="app"> <button v-on:click="toast">Toast bread</button> </div>
- As for the JavaScript, write the following:
new Vue({el:'#app', methods:{toast(){alert('Tosted!')}}})
- Run the code! An event listener will be installed on the button.
- Click the button and you should see a popup that says Toasted!