mirror of
https://github.com/sahadev/vue-component-creater-ui.git
synced 2025-06-07 21:54:05 +08:00
update: 基础的二次解析能力
This commit is contained in:
parent
1cbe8fff43
commit
e0a7222dae
@ -1,5 +1,5 @@
|
|||||||
//该文件用于解析HTML,输出为Object对象
|
//该文件用于解析HTML,输出为Object对象
|
||||||
import htmlparser2 from "htmlparser2"
|
import { Parser } from "htmlparser2"
|
||||||
|
|
||||||
function getNodeContent(node) {
|
function getNodeContent(node) {
|
||||||
return node[Object.keys(node)[0]];
|
return node[Object.keys(node)[0]];
|
||||||
@ -35,7 +35,7 @@ function parseHtml(htmlData) {
|
|||||||
let lastAccessStack = [root];
|
let lastAccessStack = [root];
|
||||||
|
|
||||||
// options docment: https://github.com/fb55/htmlparser2/wiki/Parser-options
|
// options docment: https://github.com/fb55/htmlparser2/wiki/Parser-options
|
||||||
const parser = new htmlparser2.Parser({
|
const parser = new Parser({
|
||||||
onopentag(tagname, attributes) {
|
onopentag(tagname, attributes) {
|
||||||
const newNode = generateNewNode(tagname, attributes);
|
const newNode = generateNewNode(tagname, attributes);
|
||||||
lastAccessStack.push(newNode);
|
lastAccessStack.push(newNode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user