Create react app introduces a single picture to report an error.

Why can logo but not a.png?

import React, { Component } from "react";
import "./App.css";
import logo from "./logo.svg"
import imgs from "./a.png"

let imgJson = require("./imageDatas");

function imgURL(imgDateArray) {

    for(var i=0;i<imgDateArray.length;iPP){
        var signleImageData = imgDateArray[i];
        signleImageData.imageURL =`./react-card/src/img/${signleImageData.fileName}`;
       // console.log(signleImageData.imageURL)
        return signleImageData.imageURL
        //imgDateArray[i] = signleImageData;
    }
}

var url = imgURL(imgJson);
console.log(url);

class App extends Component {

  render() {
    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
            <img src={imgs} />
          <h1 className="">Welcome to React  </h1>
        </header>
        <p className="App-intro">
          To get started, edit src/App.js and save to reload.
        

</div> ); } } export default App;

clipboard.png

Apr.01,2021

whether the file exists or not can png be added to, webpack module


https://codeshelper.com/q/10.


should not be configured with the appropriate webpack-loader, one is svg, and the other is png. Loader is different

but logically, we can handle both svg and png using url-loader.

        {
          test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
          exclude: /node_modules/,
          include: [opts.src],
          use: [
            {
              loader: 'url-loader',
              options: {
                limit: opts.urlLimit,
                name: url_name
              }
            }
          ]
        }

so at least post your configuration?

Menu