Question · Cours Vue.js · Module 15: TypeScript et Nuxt
Appeler un emit typé
Étant donné const emit = defineEmits<{ alert: [level: string, msg: string] }>(), quel appel est correct ?
Réponses possibles
- emit('alert', 'high', 'Attention !')
- emit('alert', { level: 'high', msg: 'Attention !' })
- emit.alert('high', 'Attention !')
- emit({ type: 'alert', level: 'high' })
Tu vérifieras la bonne réponse en résolvant cet exercice dans le jeu CodeWorlds.