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

138
Views
Class with conditional rendering appearing on page load when it should be rendering after conditions are met

I am trying to hide a certain class on page load. The first two texts do not appear on page load, but somehow, the third text flashes on page load but it disappears after a few seconds since the other conditions of the other classes are being met. I would like it to be hidden on page load, only to appear if the v-else-if condition is met.

This is how my code looks like:

    <div class="row">
      <div class="cxs12" v-if="this.result1 !== this.result2">
        <p>
          text 1
        </p>
      </div>
      <div class="cxs12" v-else-if="this.result">
        <p>
          text 2
        </p>
      </div>
      <div class="cxs12" id="unavailable" v-else-if="this.result === undefined">
        <p>
          text 3
        </p>
      </div>
    </div>

this.result is the return of an API call. I have already tried adding v-cloak on both the template and the CSS, but it unfortunately does not work. Note that I am using Typescript, and not Vue.js.

Any idea what I could do to fix this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can try to set another condition on row, maybe something like following snippet if I understand you correctly:

new Vue({
  el: '#demo',
  data() {
    return {
      result: undefined,
      result1: '',
      result2: '',
      loading: false
    }
  },
  methods: {
    apiCall() {
      this.loading = true
      setTimeout(()=> {
        this.result = 1
        this.loading = false
      },2000)
    }
  },
  mounted() {
    this.apiCall()
  }
})

Vue.config.productionTip = false
Vue.config.devtools = false
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <div class="row" v-if="!loading">
      <div class="cxs12" v-if="this.result1 !== this.result2">
        <p>
          text 1
        </p>
      </div>
      <div class="cxs12" v-else-if="this.result">
        <p>
          text 2
        </p>
      </div>
      <div class="cxs12" id="unavailable" v-else-if="this.result === undefined">
        <p>
          text 3
        </p>
      </div>
    </div>
</div>

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!