图片未载入反应

时间:2020-02-25 17:14:06

标签: reactjs webpack

我的图像未加载到react中,并且我的webpack配置中包含以下内容:

use: {
    loader: 'url-loader'
},
test: /\.(jpe?g|png|gif|woff|woff2|eot|ttf|svg)(\?[a-z0-9=.]+)?$/,

我没有收到错误,但是图像只是显示alt not working

<img src={require("./Images/start.jpg")} alt="not working" />

我完整的配置

module: {
    rules: [
        {
            use: {

                loader: "babel-loader"
            },
            test: /\.js$|jsx/,
            exclude: /node_modules/

        },
        {
            loader: 'file-loader',
            test: /\.(png|jpg|jpeg|gif)$/,
        }
    ]
}

1 个答案:

答案 0 :(得分:0)

在您的webpack配置文件中,尝试使用此加载器:

  calculatedFieldSettings: [
    { name: 'Binaural', formula: '"Sum(the_order_count)" == "0" ? "0" : ("Sum(the_unit_count)" - "Sum(the_order_count)") / "Sum(the_order_count)" * "100"'},
    { name: 'Av', formula: '"Sum(the_order_count)" == "0" ? "0" : "Sum(the_order_value_net)" / "Sum(the_order_count)"'},
    { name: 'Avuni', formula: '"Sum(the_unit_count)" == "0" ? "0" : "Sum(the_order_value_net)" / "Sum(the_unit_count)"'},
  ]

希望这对您有用。