2

I am trying to use a vue variable inside blade and image src attribute but vue gives template compiling errors.

Where is what I am trying to do

<img src="uploads/@{{authUser.profilePic}}"/>

I could separate this as a pure template but vue template loads little bit slower than a blade file.

Any help would be greatly appreciated.

2
  • [Vue warn]: Error compiling template: Commented Dec 13, 2017 at 14:27
  • It gives ` Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead` but if I add :src it gives different error complain about { Commented Dec 13, 2017 at 14:29

1 Answer 1

5

Interpolation inside attributes is not available on Vue 2. Instead you use v-bind:src or the shortcut :src to bind a Javascript expression to src.

<img :src="'uploads/' + authUser.profilePic"/>

The javascript expression being string concatenation:

'uploads/' + authUser.profilePic
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. Got confused with laravel's {{}} and @ but thanks again for the answer!
Yeah, you'd use @{{ var }} anywhere outside of attributes.

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.