Today I Learned - Rocky Kev

TIL properly adding files into Vue

POSTED ON:

TAGS:

This probably happens to me every other Vue Project. So might as well right about it.

*WRONG: *

var audio = new Audio('./file.mp3');

This gets decoded as a string.

*CORRECT: *

var audio = new Audio(require('./file.mp3'));

Webpack will ensure the proper path and filename for that resource.

Via https://stackoverflow.com/a/51126831/4096078


Related TILs

Tagged:

TIL How to implement two-way binding without a framework

One of the reasons we use React or Vue is because of that sweet sweet two-way binding. It's the automatic syncing of data between the model (data) and the view (UI) in both directions. Any changes made to the data will automatically update the view, and any changes made to the view will automatically update the data.

TIL Cherry-picking out of bootstrap-vue

If you are using a component library that uses ES modules like bootstrap-vue, you can cherry pick its components instead of just registering all of them globally.

TIL how Svelte is different fom Vue/React