[Vuejs]-How to use S3 bucket URL as the base URL for images on components

0👍

Correct. Don’t hang variables off the window if you’re not in a UMD environment.

Instead, you could just assign this to vue directly:

Vue.prototype.$s3bucket =  'https://myassets.s3.us-east-2.amazonaws.com';

Notice I’ve used $ above so you don’t have potential collisions.

Then just use:

:src=`${$s3bucket}/user/${userimage}...`

(You don’t have to use template strings, I just prefer the syntax)

Leave a comment