auto-toc-js
v1.0.0
Published
自动搜索网页中的标题,生成具有层次结构的文章目录的js插件
Readme
auto-toc-js
自动搜索网页中的标题,生成具有层次结构的文章目录的js插件
内容
浏览器兼容性
| IE | Firefox | Chrome | Safari | iOS | Android | |:---------:|:---------:|:---------:|:---------:|:---------:|:---------:| | IE9+ | ✓| ✓ | ✓ | ✓ | ✓ | ✓
功能特性
- [x] 使用简单,引入JavaScript文件即可
- [x] 配置灵活
- [x] 持续维护迭代
安装
NPM
npm install auto-toc-jsCDN
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/toc.min.js"></script>使用
<script src="../dist/toc.min.js"></script>
<script>
new Toc({
wrapperId: 'wrap',
insertId: 'wrap',
showSerial: true
}).createToc();
</script>案例
请查看example
配置项
|key|description|default|val|
|:---|---|---|---|
|wrapperId|需要生成toc目录的容器id| - |String|
|insertId|位置id,toc目录面板将插入在此id代表的元素的前面| - |String|
|showSerial|是否显示目录序号|false|Boolean|
个别特殊配置项说明
1.目录样式需要自行添加,可参考
示例中的样式代码。
历史版本
See the GitHub 历史版本.
贡献
欢迎给出一些意见和优化,期待你的 Pull Request
