[Vuejs]-Data bound v-if dynamic condition

0👍

Execute JavaScript code stored as a string can be dangerous. Think twice if you really need it…

<a class="LAYOUTfooter9_social_image_container" :href="social.url" v-for="(social,index) in $app.globals.socialLinks" v-if="evaluateCondition(social.v-if)" :key="index+'S'">
methods: {
  evaluateCondition(condition) {
    return eval(condition)
  }
}

Your conditions have to be an expression and will be executing in the context of Vue instance so instead of $app.auth you need to use this.$app.auth

Leave a comment