1

I have defined an icon component and I want the props to be attached to the href link address as part of the URL. How can this be done correctly?

In fact, I want the amount of attribute href to look like this:

href="./img/icon.svg#ico_copy"

Vue.component('icon', {
  template: `
  <svg class="iconz">
  <use v-bind:href="'./img/icon.svg#'+ props.label"></use>
  </svg>`,
  props: {
    label: String,
  },
});
  <icon label="ico_copy"></icon>

0

1 Answer 1

1

you can create a computed property like this:

computed: {
  url() {
    return `./img/icon.svg#${this.label}`;
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.