问题描述
我使用Epubjs-rn
打开Epub图书
我有rendition
方法中的onSelected
,但我想在打开书本时得到rendition
,并通过cfi突出显示一些文本
我的代码:
onSelected={(cfiRange,rendition) => {
console.log("text is selected");
this.setState({ selectedCfi: cfiRange });
rendition.highlight(cfiRange,{},(e) => { console.log(e) },undefined,{ 'fill': 'lightblue' });
}}
解决方法
我用ref
组件的epub
来解决这个问题,
<Epub
ref={ref => this.epub = ref}
// other props
/>
然后您可以这样称呼:
this.epub.rendition.highlight(...)