将wiki升级为vue3版本
This commit is contained in:
23
zyplayer-doc-ui/wiki-ui-2/src/assets/lib/HtmlUtil.js
Normal file
23
zyplayer-doc-ui/wiki-ui-2/src/assets/lib/HtmlUtil.js
Normal file
@@ -0,0 +1,23 @@
|
||||
export default {
|
||||
createNavigationHeading() {
|
||||
let headArr = []
|
||||
let headNodeArr = document
|
||||
.querySelector('.wiki-page-content')
|
||||
.querySelectorAll('h1,h2,h3,h4,h5,h6')
|
||||
if (headNodeArr.length <= 0) {
|
||||
return []
|
||||
}
|
||||
headNodeArr.forEach((node) => {
|
||||
let text = node.innerHTML
|
||||
.replace(/^\s+/g, '')
|
||||
.replace(/\s+$/g, '')
|
||||
.replace(/<\/?[^>]+(>|$)/g, '')
|
||||
headArr.push({
|
||||
node: node,
|
||||
level: parseInt(node.tagName.replace(/[h]/i, ''), 10),
|
||||
text: text,
|
||||
})
|
||||
})
|
||||
return headArr
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user