Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

298
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!