0

I'm working on a RealWord App for Vue project. I'm trying to find a way to hide the phrase "test", so that it cannot show any article with the "test" phrase.

TagList.vue Component:

<template>
  <ul class="tag-list">
    <li
      class="tag-default tag-pill tag-outline"
      v-for="(tag, index) of tags"
      :key="index"
    >
      <span v-text="tag" />
    </li>
  </ul>
</template>

<script>
export default {
  name: "TagList",
  props: {
    tags: Array
  }
};
</script>

1 Answer 1

1

To hide tags that contain "test", use a computed prop to get a filtered array of tags[]:

export default {
  computed: {
    filteredTags() {
      return this.tags.filter(tag => tag !== 'test')
    }
  }
}

Then, update your v-for to use this computed prop:

<li v-for="(tag, index) of filteredTags">
Sign up to request clarification or add additional context in comments.

1 Comment

i think it works very well but there is error says "Error in render: "ReferenceError: tags is not defined"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.