Vue2 use @ alias in computed property

Viewed 21

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';
  }
}
1 Answers

Use require for relative path imports in javascript

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