//CustomPlugin.js
const generateRandomValue = (min, max) => {
min = Math.ceil(min);
max = Math.floor(max);
const random = Math.floor(Math.random() * (max - min + 1)) + min;
console.log(random);
};
export default {
install(Vue) {
Vue.config.globalProperties.$generateRandomValue = generateRandomValue;
},
};
//App.vue
<template>
<button>event</button>
</template>
This code represents an illustration. I aim to invoke the generateRandomValue function within <script setup>
and place it within a button instead of
<buton@click="$generateRandomValue(0, 20)">
The subsequent is a model of what I aspire to achieve.
//App.vue
<template>
<button @click="random">event</button>
</template>
<script setup>
const random = $generateRandomValue(0,10);
</script>
What steps should I follow for this task?