Passing Parameters to a Method in Vue
You can pass parameters to methods that are bound as handlers. Let's see in practice. Let's say we have the following method that takes a message as a parameter that needs to be output:
methods: {
show: function(str) {
alert(str);
}
}
Let's bind this method to different tags, passing it the text to be output as a parameter:
<template>
<button @click="show('text1')">btn1</button>
<button @click="show('text2')">btn2</button>
</template>
Create a method that will take a number as a parameter and output the square of this number through alert.
Make two buttons. When you press the first button, print the square of 2, and when you press the second button, print the square of 3.