[Vuejs]-Rendering v-show based on if data does not contains "n/a" | N/A| NOT AVAILABLE

0👍

You could do something like

checkHTML(html) {
  // check the html string with this regex pattern to see if it contains 
  // not available, n/a or N/A
  if (html.match(/([Nn]\/[Aa])|(not available)/g)) {
    // if it does include those words return false (hide the div)
    return false;
  } else {
    // if it doesn't include the words (yay!) you can return true (show the div)
    return true;
  }
}

then in your markup use it like so

<p v-if="checkHTML(selectedJob.OData__x0071_21)" v-html="selectedJob.OData__x0071_21"></p>

Leave a comment