Module not found: error: cannot resolve 'DavidDaDon.png'
P粉001206492
P粉001206492 2023-07-27 21:01:30
0
1
522

I'm not quite sure what I'm doing wrong here. I placed the PNG images in the src folder and used require and relative paths to reference the images. I feel like I'm going crazy. For reference, I'm creating a countdown to celebrating birthdays with close friends and family. The images will eventually become an accordion showing a countdown to their respective birthdays. At the end of the countdown, a text box will appear to speak to them. I also created an Accordian component to contain the working code. Maybe I imported the file twice? I have imported both in accordian file and app.js file.

import Accordian from './accordian'; import AugustusDaGreat from './AugustusDaGreat.png'; import DadMatt from './Dad-Matt.png'; import DavidDaDon from 'DavidDaDon.png'; import propic from './propic.png'; import RickyKyle from './RickyKyle.png'; // import 5 pngs of friends const gus = AugustusDaGreat; const dadMatt = DadMatt; const daveDaDon = DavidDaDon; const profilePic = propic; const bigDickRick = RickyKyle; function App(props) { return ( 

Never Miss A Birthday!

dad
); }

I've tried using require in the src attribute and naming the files using const variables.

P粉001206492
P粉001206492

reply all (1)
P粉768045522

Can you show us your mistake? What does it say? Also, in the fourth line of the code you pasted, you forgot './'. Please use this instead of

import DavidDaDon from 'DavidDaDon.png';

should look like this

import DavidDaDon from './DavidDaDon.png';
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!