我正在尝试将react epub阅读器与Next Js集成,但遇到一个错误,并且与react Js配合良好,我需要您的帮助将epub阅读器集成到Next Js
错误
我的代码
import React from 'react';
import { ReactReader } from "react-reader";
export default function Home() {
return (
<div>
<div style={{ position: "relative", height: "330px" }}>
<ReactReader
url="./Boy without a name English.epub"
title={"Alice in wonderland"}
location={"epubcfi(/6/2[cover]!/6)"}
locationChanged={epubcifi => console.log(epubcifi)}
/>
</div>
</div>
)
}
可以通过传输react-reader
和epubjs
模块(几个月前导出为ESM(来解决此问题。
例如,在Next.js-config:中使用next-transpile-modules
// next.config.js
const withTM = require("next-transpile-modules")(["react-reader", "epubjs"]);
module.exports = withTM({/* custom config */});