[Vuejs]-Get file from directory in vue.js component

0👍

Vue cli’s WebPack is probably not parsing that content as an asset. One workaround is to use require():

<div :style="'background-image:url(' + require('../../assets/img/bkgds/cheesecloth-herbs-bk.jpg') + ');'">

Check a demo CodeSandbox here.

Leave a comment