Tertiadecima
Tertiadecima

Reputation: 85

emit in fuction in vue 3 composition api

I have a timer, and a function by which the timer stops. I want to use emit in a function, it doesn't work.

 const stopTimer = () => {
  clearInterval(timer.value);

  const emit = defineEmits(["end"]);
  emit("end", reactionTime.value);
};

Upvotes: 1

Views: 1921

Answers (1)

TheAlexLichter
TheAlexLichter

Reputation: 7299

defineEmits should be called top-level in <script setup> and not inside any arrow function.

Upvotes: 3

Related Questions