| | |
| | | </div> |
| | | </div> |
| | | <!-- 100 --> |
| | | <div class="page-box"> |
| | | <div class="page-box" page="100"> |
| | | <even-header :num="100" /> |
| | | <div class="padding-96"> |
| | | <p> |
| | |
| | | this.throttleThreshold, |
| | | { leading: true, trailing: false } |
| | | ); |
| | | // 提供页面跳转功能 |
| | | if (this.setGlobalState) { |
| | | this.setGlobalState({ |
| | | gotoPage: (catalog, page) => { |
| | | this.gotoPage(catalog, page); |
| | | } |
| | | }); |
| | | } |
| | | // 测试页面跳转 |
| | | // setTimeout(() => { |
| | | // this.gotoPage(5, 100); |
| | | // }, 3000); |
| | | }, |
| | | methods: { |
| | | scrollFun(e) { |
| | | |
| | | // 判断向上滚动还是向下滚动 |
| | | if (event.target.scrollTop > this.previousScrollTop) { |
| | | console.log("向下滚动"); |
| | |
| | | console.log(this.showCatalogList); |
| | | // 更新上一次滚动的位置 |
| | | this.previousScrollTop = event.target.scrollTop; |
| | | }, |
| | | gotoPage(catalog, page) { |
| | | if (catalog >= 0 && catalog <= this.catalogLength) { |
| | | // 处理渲染章节 |
| | | if (catalog == 0) { |
| | | this.showCatalogList = [0, 1]; |
| | | } else if (catalog == this.catalogLength) { |
| | | this.showCatalogList = [ |
| | | this.catalogLength - 2, |
| | | this.catalogLength - 1, |
| | | this.catalogLength |
| | | ]; |
| | | } else { |
| | | this.showCatalogList = [catalog - 1, catalog, catalog + 1]; |
| | | } |
| | | setTimeout(() => { |
| | | // 跳转页码 |
| | | const pageDom = document.querySelector(`[page="${page}"]`); |
| | | if (pageDom) { |
| | | pageDom.scrollIntoView(); |
| | | } else { |
| | | console.log("页码错误!"); |
| | | } |
| | | }, 50); |
| | | } else { |
| | | console.log("章节错误!"); |
| | | } |
| | | } |
| | | }, |
| | | components: { |
| | |
| | | let instance = null; |
| | | |
| | | function render(props = {}) { |
| | | const { container } = props; |
| | | const { container, onGlobalStateChange, setGlobalState } = props; |
| | | Vue.prototype.onGlobalStateChange = onGlobalStateChange; |
| | | Vue.prototype.setGlobalState = setGlobalState; |
| | | instance = new Vue({ |
| | | // router, |
| | | store, |
| | |
| | | // export async function update(props) { |
| | | // render(props); |
| | | // } |
| | | |