W
W
weraleto2020-01-28 22:43:34
JavaScript
weraleto, 2020-01-28 22:43:34

How to hang a vue event?

I'm writing a site on vue.js, I can't hang the @click event on the "yes" - "no" buttons (and generally does not work on any element of the table tag)
what could be the reason?

component code https://github.com/weraleto/new/blob/master/1.vue
demo can be viewed here weraleto.ru/quiz
(questionnaire stage 3)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex, 2020-01-28
@Kozack

I guess this is because you don't pass a function as a handler. And just call this function.

// Ошибка
@click="$emit('onminus')"

// Правильно
@click="() => $emit('onminus')"

A
Athanor, 2020-01-29
@Athanor

All the same, I suspect that you incorrectly subscribed to the event in the parent. I sandboxed your component, subscribed to onplus and onminus in the parent, and everything works. Demo

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question