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:
App.vuemethods: {
show: function(str) {
alert(str);
}
}
Let's bind this method to different tags, passing it the text to be output as a parameter:
App.vue<template>
<button @click="show('text1')">btn1</button>
<button @click="show('text2')">btn2</button>
</template>
Задание 1
Create a method that will take a number as a parameter and output the square of this number through alert.
Задание 2
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.