Images not loading in React

前端 未结 3 1293
野的像风
野的像风 2021-01-19 10:44

not able to display the image getting an error as not found but i have provided the full path for it. I don\'t know where i am going wrong.

class App extend         


        
3条回答
  •  盖世英雄少女心
    2021-01-19 11:28

    If you are using webpack, you need to use require while mentioning the src for img tag. Also the url must be relative to the component.

    class App extends React.Component {
    
       render() {
          return (
             

    hello

    cannot display
    ); } } export default App;

    If you are not using webpack then simplly wrapping the src value within {} will work

    class App extends React.Component {
    
       render() {
          return (
             

    hello

    cannot display
    ); } } export default App;

提交回复
热议问题