Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue/require-explicit-emits - defineModel not supported #2544

Open
Pentadome opened this issue Sep 4, 2024 · 1 comment
Open

vue/require-explicit-emits - defineModel not supported #2544

Pentadome opened this issue Sep 4, 2024 · 1 comment

Comments

@Pentadome
Copy link

What did you do?

<script setup lang="ts">
defineModel<string>();
</script>

<template>
  <input @input="$emit('update:modelValue', $event.target.value)" />
</template>

This causes warning/error: The "update:modelValue" event has been triggered but not declared on defineEmits.

@FloEdelmann
Copy link
Member

Is this the recommended usage? I'd rather do this with defineModel:

<script setup lang="ts">
const modelValue = defineModel<string>();
</script>

<template>
  <input @input="modelValue = $event.target.value" />

  <!-- or even better: -->
  <input v-model="modelValue" />
</template>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants