Using require('…') with a variable vs. using a string in webpack

前端 未结 2 1930
孤独总比滥情好
孤独总比滥情好 2020-11-29 09:40

I have a problem that doesn\'t make much sense to me.

I\'m mapping an array of objects that have a \"name\" and a \"href\" property.

let appleIcons         


        
2条回答
  •  遥遥无期
    2020-11-29 10:09

    Adding an empty string fixed the problem for me. So, below code should work:

    let appleIcons = _.map(appleIcons, appleIcon => {
      appleIcon.href = require('' + appleIcon.href);
      return appleIcon;
    });
    

提交回复
热议问题