Home  >  Q&A  >  body text

How to add require('path/to/your/source') in returned data (array)

From the returned data, there is the src address of img, <img :src="item.img_url" alt="">, but the src address path will not be compiled by webpack , and still maintains the relative path status, eventually generating a 404 error.
How to solve it?

曾经蜡笔没有小新曾经蜡笔没有小新2590 days ago525

reply all(1)I'll reply

  • 仅有的幸福

    仅有的幸福2017-06-12 09:29:38

    After you use ajax to get the array containing these img_url, it will be processed immediately

    Similar to this

    function url_parse(arr){
        return arr.map(item => {
            item.img_url = xxxxxxxxxxxxxxxxxxx; 
            return item; 
        }); 
    }
    
    imgArr = url_parse(imgArr); 

    reply
    0
  • Cancelreply