1.1.2 • Published 2 years ago

@xinghe/toc v1.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

Table of contents

Crawling all heading tags of page and generating TOC automatically.

Styling TOC by your self.

Install

  • Module
npm i @xinghe/toc -S
# or
yarn add @xinghe/toc -S
  • CDN
<script src="https://unpkg.com/@xinghe/toc@1.0.1/lib/index.umd.js" />

Usage

new TOC({ el: '#toc' });

Configuration

FieldTypeRequiredComment
elHTMLElement、StringYthe root element which toc needs to be mounted
modeStringNthe way of anchor, default to hash, but you can use scroll which means scrollIntoView in JS
containerHTMLElement、StringNthe root element which contains headings, the default is document.body
selectorStringNcss selector of heading tags, default is h1 ~ h6
beforeMountFunctionNlife-cycle hook called before toc mount
onMountedFunctionNlife-cycle hook called after toc mounted
cleanRootBooleanNclean root element before mounting doms
1.1.1

2 years ago

1.1.0

2 years ago

1.1.2

2 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago