当前位置: 代码迷 >> 综合 >> epub.js使用
  详细解决方案

epub.js使用

热度:68   发布时间:2023-11-07 01:53:14.0
<div id="viewer"></div>

1.引入图书路径,需是epub类型,(method需为default,要么苹果端加载为空白)

var book = ePub("epub/三国演义.epub", {
    openAs: "epub"
});var rendition = book.renderTo("viewer", {
    restore: true,width: '100%',height: "100%",method: 'default',
});

2.渲染图书

rendition.display();

3.获取章节导航

book.loaded.navigation.then(function(toc) {
    console.log(toc)
});

4.点击屏幕左右两侧进行上下翻页,获取坐标进行判断左右,下面只介绍方法

book.rendition.on('click', (event, contents) => {
    book.rendition.prev()  //上一页book.rendition.next()  //下一页
})

5.设置内容文字大小

var themes = rendition.themes

绑定事件设置大小

themes.fontSize(24 + 'px')