3.3

mask
prevPage
nextPage


<template>
<div class="ebook">
<div class="read-wrapper">
<div id="read"></div>
<div class="mask">
<div class="left" @click="prevPage"></div>
<div class="center"></div>
<div class="right" @click="nextPage"></div>
</div>
</div>
</div>
</template>

<script>
import Epub from "epubjs";
const DOWNLOAD_URL = "/static/2018_Book_AgileProcessesInSoftwareEngine.epub";
export default {
data() {
return {
book: {},
rendition: {},
};
},

components: {},

computed: {},

mounted() {
this.showEpub();
},

methods: {
showEpub() {
// 生成book对象
this.book = new Epub(DOWNLOAD_URL);

  // 生成rendition 对象
  this.rendition = this.book.renderTo("read", {
    width: window.innerWidth,
    height: window.innerHeight,
  });

  // 渲染节点
  this.rendition.display();
},
// 点击上一页
prevPage() {
  if (this.rendition) {
    this.rendition.prev();
  }
},
// 点击下一页
nextPage() {
  if (this.rendition) {
    this.rendition.next();
  }
},

},
};
</script>
<style lang="scss" scoped>
@import "assets/styles/global.scss";
.ebook {
position: relative;
.read-wrapper {
.mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 100;
display: flex;
.left {
flex: 0 0 px2rem(100);
}
.center {
flex: 1;
}
.right {
flex: 0 0 px2rem(100);
}
}
}
}
</style>

@import "./reset.scss";

$fontSize: 37.5;

@function px2rem(px) { @return (px / $fontSize) + rem;
}

@mixin center() {
display: flex;
justify-content: center;
align-items: center;
}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容