S
S
SimBioT192020-09-29 12:16:11
JavaScript
SimBioT19, 2020-09-29 12:16:11

How would you simplify the component?

<template>
    <div :class="className">
        <svg class="icon-svg">
            <use :xlink:href="`#icon-${icon}`"></use>
        </svg>
    </div>
</template>

<script>
export default {
  name: 'VIcon',
  props: {
    icon: {
      type: String,
      required: false,
    },
    size: {
      type: String,
      required: false,
    },
  },
  computed: {
    className() {
      const classList = ['icon'];

      if (this.size) {
        classList.push(`icon--${this.size}`);
      }
      return classList;
    },
  },
};
</script>


Maybe there are options to make the elementary component even simpler?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question