Parcel JS VUE dynamic images :src

后端 未结 1 1942
醉酒成梦
醉酒成梦 2020-12-19 07:17

Vue js with parcel bundler cannot load dynamic images

  • 1条回答
    •  野趣味
      野趣味 (楼主)
      2020-12-19 07:56

      Slightly old, but this is how I just did it, maybe it will help.

      Imagine you're trying to do the following, where some parts of the path are dynamic:

      
      

      You would naturally think to do something like:

      
      

      And expect it rendered like:

      
      

      ..But because parclejs looks at your code to bundle and move assets into ./dist it won't see the dynamic image, so it won't get moved.

      A solution is to import all the images, then use that to access the real path:

      
      
                                       
                    
    提交回复
    热议问题