Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

334
Visualizações
how to remove deprecated $listeners in vue 3

In migration from vue 2 to vue 3, i am getting some compilation warnings. Deprecation of $listeners in components is one of those warnings. I have checked official documentation to use $attrs by removing $listeners. I am new in vue 3. So, not able to understand how to handle those warnings related to listeners.

Here is the snippet: 1st case: Component 1

    <template>
    <div>
        <input ref="input"
               :value="txtField"
               @input="txtField=$event.target.value"
               :type="inputType"
               :class="inputClass"
               :placeholder="placeholder"
               :disabled="disabled"
               :readonly="readonly"
               :onfocus="disabled&&'this.blur();'"
               :tabindex="tabindex"
               v-on="listenersInput" // here is the method where $listeners used
               @keyup.enter="enterHandler"
               @blur="validateOnEvent"/>
     </div>
</template>

//method 

listenersInput() {
            //var vm = this;
            return Object.assign({}, this.$listeners, {
                input: function(event){ /*vm.$emit('input',event.target.value);*/}
            });
        },

2nd case: Component 2

    <template>
    <custom-button v-bind="buttonProps"
                 v-on="$listeners"
                 :class="buttonClass"
                 @click="tooggle"></custom-button>
</template>

How to handle these two cases?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In Vue 3 $listeners moved to $attrs you can use v-bind="$attrs". Here is an article from docs

Additional documentation: https://vuejs.org/guide/components/attrs.html#nested-component-inheritance

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda