【问题标题】:How to Integrate React Epub Reader with next js如何将 React Epub 阅读器与下一个 js 集成
【发布时间】:2021-04-06 17:03:57
【问题描述】:

我正在尝试将react epub reader 与 Next Js 集成,但出现一个错误,并且与 react js 配合良好,我需要您的帮助来将 epub 阅读器与 next js 集成

error

我的代码

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>
  )
}

【问题讨论】:

标签: javascript reactjs next.js server-side-rendering


【解决方案1】:

可以通过转译 react-readerepubjs 模块(几个月前作为 ESM 导出)来解决此问题。

例如,在 Next.js 配置中使用 next-transpile-modules

// next.config.js
const withTM = require("next-transpile-modules")(["react-reader", "epubjs"]);

module.exports = withTM({/* custom config */});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-29
    • 2012-05-17
    • 1970-01-01
    • 1970-01-01
    • 2019-12-25
    • 1970-01-01
    • 2017-12-28
    相关资源
    最近更新 更多