基于Vue的侧边目录组件的实现

2020-06-16 06:53:26易采站长站整理
为每级目录指定标签refListArray–为每级目录指定ref元素,数组每项为对象,包含两个属性<ul><li>ref(必需)该行目录对象的refName</li><li>title该行目录的名称(默认取innerText)</li><li>level(默认为1)该行目录级别</li></ul>containerElementSelectorString–(必需)指定文章的容器scrollElementSelectorStringWindow需要添加scroll事件的css选择器,默认监听window的scroll事件openDomWatchBooleanfalse是否开启dom监听,如果containerElementSelector中有dom变化会重新计算每级目录的offsetTop

Methods

NameParametersDescription
initActive使目录第一行处于active状态
setRefList计算每级目录的offsetTop

Slot

NameDescription
目录的题目