我正在尝试使用epub.js库,并试图让这些基本功能运行。问题是电子书没有显示在我的浏览器中:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/epubjs/dist/epub.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
<title>Document</title>
</head>
<body>
<div id="area"></div>
</body>
<script>
var book = ePub("steinbeck-of-mice-and-men.epub", { openAs: "epub" });
var rendition = book.renderTo("area", {width: 600, height: 400});
var displayed = rendition.display();
book.renderTo("area", { method: "default", width: "100%", height: "100%" });
</script>
</html>我的目录中有steinbeck-of-mice-and-men.epub,但它只是一个空白页。
发布于 2022-02-18 06:36:59
看来你的路不对。如果文件位于保存HTML的同一目录中,则使用正确的路径。
<script>
var book = ePub("./steinbeck-of-mice-and-men.epub", { openAs: "epub" });
var rendition = book.renderTo("area", {width: 600, height: 400});
var displayed = rendition.display();
// book.renderTo("area", { method: "default", width: "100%", height: "100%" }); // why are you rendering it again?
</script>您可以查看文档这里。
https://stackoverflow.com/questions/71166156
复制相似问题