Next.js13使用react-speech-recognition遇regeneratorRuntime未定义错误求助
Next.js 13 + Redux Toolkit 中遇到
ReferenceError: regeneratorRuntime is not defined 错误求助 我在Next.js 13项目中搭配Redux Toolkit开发,现在遇到了ReferenceError: regeneratorRuntime is not defined错误。项目代码位于nextjsfrontend分支,我是Web开发新手,希望能得到解决帮助。
我已经按照react-speech-recognition的官方文档指引,执行了npm install regenerator-runtime并在_app.js中导入,但错误仍然存在。
触发错误的SpeechRecognitionComponent文件代码
import React from 'react' import SpeechRecognition, {useSpeechRecognition} from "react-speech-recognition" function SpeechRecognitionComponent() { const { transcript, interimTranscript, finalTranscript, resetTranscript, listening, } = useSpeechRecognition(); if (!browserSupportsSpeechRecognition) { return <span>Browser doesn't support speech recognition.</span>; } return ( <> <div> <p>Microphone: {listening ? 'on' : 'off'}</p> <button onClick={SpeechRecognition.startListening}>Start</button> <button onClick={SpeechRecognition.stopListening}>Stop</button> <button onClick={resetTranscript}>Reset</button> <p>{transcript}</p> </div> </> ) } export default SpeechRecognitionComponent
layout.js文件代码
import './globals.css' import { Providers } from "@/redux/provider"; export const metadata = { title: 'Leo GPT', description: 'An AI that immitates me', } export default function RootLayout({ children }) { return ( <html lang="en"> <body> <Providers> <header> <h2>Leo GPT</h2> </header> {children} </Providers> </body> </html> ) }
_app.js文件代码
import 'regenerator-runtime/runtime' export default function MyApp({ Component, pageProps }) { return <Component {...pageProps} />; }
内容的提问来源于stack exchange,提问作者Leotheperegrine
相关产品推荐
相关产品推荐

