翻页是翻了,可是有个问题,每次翻页直接到下一章节了,很奇怪。

来源:3-3 电子书翻页功能实现

彭小呆

2018-10-23 17:52

翻页是翻了,可是有个问题,每次翻页直接到下一章节了,很奇怪。


import Epub from 'epubjs'
const DOWNLOAD_URL = '/static/kill-a-bird.epub'
export default {
  name: 'Ebook',
  methods: {
    prevPage () {
      if (this.rendition) {
        this.rendition.prev()
      }
    },
    nextPage () {
      if (this.rendition) {
        this.rendition.next()
      }
    },
    // 电子书的解析和渲染
    showEpub () {
      // 生成Book
      this.book = new Epub(DOWNLOAD_URL)
      console.log(this.book)
      // 生成Rendition,通过Book.renderTo
      this.rendition = this.book.renderTo('read', {
        width: window.innerWidth,
        height: window.innerHeight
      })
      // 通过Rendition.display
      this.rendition.display()
    }
  },
  mounted () {
    this.showEpub()
  }
}


写回答 关注

1回答

  • Sam
    2018-10-23 19:11:53

    你好,源码中没有看出问题,可以提供完整源码看下

    彭小呆

    我换了一个浏览器就可以,低版本的好像不行

    2018-10-25 16:21:14

    共 1 条回复 >

快速入门Web阅读器开发

带你了解电子书阅读器的工作原理,通过Vue.js快速实现Web阅读器

26238 学习 · 214 问题

查看课程

相似问题