老师您好,请问搜索全书内容后跳转到指定位置后阅读的进度会随之改变吗
来源:5-14 全文搜索功能实现 (搜索关键字高亮+搜索结果高亮显示)
学者___
2019-01-26
写回答
2回答
-
你好,全文搜索后跳转到指定位置,阅读进度会随之改变。因为跳转时调用的mixin.js中的display()方法,该方法会调用refreshLocation()方法,刷新阅读位置。
062019-01-27 -
学者___
提问者
2019-01-27
//搜索列表项 <div class="slide-search-item" v-for="(item, index) in searchList" :key="index" v-html="item.excerpt" @click="displayContent(item.cfi, true)"> </div> //调用display() displayContent (target, highlight = false) { this.display(target, () => { this.hideTitleAndMenu() if (highlight) { this.currentBook.rendition.annotations.highlight(target) } }) } //display()调用refreshLocation() display (target, cb) { if (target) { this.currentBook.rendition.display(target).then(() => { this.refreshLocation() if (cb) cb() }) } else { this.currentBook.rendition.display().then(() => { this.refreshLocation() if (cb) cb() }) } } //refreshLocation()方法 refreshLocation () { const currentLocation = this.currentBook.rendition.currentLocation() if (currentLocation && currentLocation.start) { const startCfi = currentLocation.start.cfi const progress = this.currentBook.locations.percentageFromCfi(startCfi) this.setProgress(Math.floor(progress * 100)) this.setSection(currentLocation.start.index) saveLocation(this.fileName, startCfi) } }
00
相似问题