Last active
July 18, 2024 14:07
-
-
Save noeleo25/c904dde6672849f264d7f65dd0daf1d3 to your computer and use it in GitHub Desktop.
Vue component for Custom Button
Click won't work in vue version 2, a possible solution is to use $emit, but what to do with event modifiers?
<template> <button :type="btnType" @click="$emit('click')" class="primary-btn"> <slot> </slot> </button> </template>
Smart people came up with everything before us, albeit in Russian https://ru.stackoverflow.com/questions/891823/%D0%9F%D0%B5%D1%80%D0%B5%D0%B4%D0%B0%D1%87%D0%B0-%D0%B2-%D0%BA%D0%BE%D0%BC%D0%BF%D0%BE%D0%BD%D0%B5%D0%BD%D1%82-%D0%B2-%D0%BA%D0%B0%D1%87%D0%B5%D1%81%D1%82%D0%B2%D0%B5-%D0%BF%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80%D0%B0-%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D0%B8-vue-js
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Click won't work in vue version 2, a possible solution is to use $emit, but what to do with event modifiers?
<template> <button :type="btnType" @click="$emit('click')" class="primary-btn"> <slot> </slot> </button> </template>