user616
user616

Reputation: 855

Vue2 use @ alias in computed property

I can't seem to find anything stating a way to use the @ src alias inside of a computed property. Is this possible?

I would like to dynamically assign an img src based on the component type. But computed property will only return back the literal string value.

computed: {
  dynamicImgSrc() {
    return '@/assets/icons/myImage.svg';
  }
}

Upvotes: 0

Views: 278

Answers (1)

Vojin Purić
Vojin Purić

Reputation: 2385

Use require for relative path imports in javascript

return require('@/assets/icons/myImage.svg')

Upvotes: 2

Related Questions