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

297
Visualizações
Buefy field does not react on :message param change

I have a Nuxt project with Buefy components. There is a form with some field component which should react on error according the message parameter for this component. But does not. I can see the correct value in debuger but component does not show the message. :message property should work like the in first email example from documentation

The code looks like:

<template #company>
    <h2 class="title">{{ $t('general.login.create_company') }}</h2>
    <b-field
        :type="loginErrors.company_name ? 'is-danger' : ''"
        :message="loginErrors.company_name ? loginErrors.company_name : ''"
    >
        <b-input
                v-model="companyName"
                name="company_name"
                type="text"
                autocomplete="off"
                :placeholder="$t('general.login.create_company')"
        ></b-input>
    </b-field>
    <div class="buttons is-centered">
        <b-button type="is-primary is-light" @click="createCompany">Save</b-button>
    </div>
</template>

...

data() {
    return {
        ...
        loginErrors: {},
        error: 'aaaaaa',
    };
},
...
async createCompany() {
    const result = await this.$api.users.createCompany({company_name: this.companyName});

    if( result.error ) {
        this.loginErrors.company_name = result.error;  // This does not work although the variable has correct value set
        this.error = result.error;  // This works fine
        return false;
    }
},

I use this pattern in other components and it works. I dont understand it. thaks for any help.

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

0

change detection of data objects in Vue is shallow (top level only)

In vue.js, Dynamically added property to an object is not reactive. Instead we can assign a whole object so that change detection happen.

For a better understanding please go through this official documentation of Vue.

Demo :

new Vue({
  el: '#app',
  data() {
    return {
      loginErrors: {}
    }
  },
  mounted() {
    this.loginErrors = {
      company_name: 'some value'
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <p>{{ loginErrors.company_name ? 'is-danger' : 'no-danger' }}</p>
</div>

about 4 years ago · Juan Pablo Isaza Relatório

0

I don't think Vue components react to object property changed in a direct way, you could try this.$set(this.loginErrors, 'company_name', result.error); instead of this.loginErrors.company_name = result.error;

FYI: https://v2.vuejs.org/v2/guide/reactivity.html?redirect=true#Change-Detection-Caveats

about 4 years ago · Juan Pablo Isaza Relatório

0

The solution in this case was to update Buefy version from 0.4.11 to 0.4.21. This fix the issue. Another thing is that is causes new issue with :type in combination with grouped param.

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