Home » vue » Check if in created() vuejs?

Check if in created() vuejs?

Posted by: admin November 26, 2021 Leave a comment

Questions:
data() {
  return: {
     checkValue: false,
     loading: 'success',
 }
},
created() {
    if (this.loading == 'success') {
     this.checkValue = true;
    }
}


//template
    <div v-if="this.checkValue == true">
         <div class="row">
             <div class="col-lg-12">
                 <a-form-item label="Photo Background Spotlight">
                     <a-radio-group
                        <a-radio value="1">Jony</a-radio>
                        <a-radio value="2">veart</a-radio>
                     </a-radio-group>
                 </a-form-item>
             </div>
        </div>
    </div>

I gave checkValue == true in created. But it still doesn’t show the template option radio.Where did I go wrong. Give me your opinion. Thank you

Answers:

You don’t need to use this in a template.
Replace <div v-if="this.checkValue == true"> with <div v-if="checkValue">.
As the check value is of type boolean you don’t need to check it for true.