最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to fix the Cannot find module mp3 file or its corresponding type declarations - Stack Overflow

programmeradmin3浏览0评论

How to fix the error Cannot find module './audio/audio1.mp3' or its corresponding type declarations. also already use the require('./audio/audio1.mp3') and also getting an error.

How to fix the error Cannot find module './audio/audio1.mp3' or its corresponding type declarations. also already use the require('./audio/audio1.mp3') and also getting an error.

Share Improve this question asked Feb 21, 2022 at 11:05 ABCABC 8326 gold badges20 silver badges45 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Inside the src/react-app-env.d.ts add this:

/// <reference types="react-scripts" />
    declare module '*.mp3'; // '*.wav' if you're using wav format

Now you can use it like this:

import audio1 from './audio/audio.mp3';

const myAudio = new Audio(audio1);
发布评论

评论列表(0)

  1. 暂无评论