mini-program-parser
Advanced tools
| Component({ | ||
| options: { | ||
| addGlobalClass: true, // page样式影响组件内样式 | ||
| }, | ||
| properties: { | ||
| tableData: { type: [Array] }, | ||
| }, | ||
| data: { | ||
| parserData: null, | ||
| }, | ||
| observers: { | ||
| tableData(data) { | ||
| if (!data) return; | ||
| const { children } = data; | ||
| if (!children) return; | ||
| const parserData = data; | ||
| const wrapper = children.filter((item) => | ||
| ["thead", "tbody"].includes(item.name) | ||
| ); | ||
| if (wrapper) { | ||
| parserData.children = []; | ||
| wrapper.forEach((item) => { | ||
| parserData.children = [...parserData.children, ...item.children]; | ||
| }); | ||
| } | ||
| console.log(parserData); | ||
| this.setData({ | ||
| parserData, | ||
| }); | ||
| }, | ||
| }, | ||
| }); |
| { | ||
| "component": true, | ||
| "usingComponents": { | ||
| "render": "../render/index" | ||
| } | ||
| } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
@@ -0,1 +1,3 @@ | ||
| import { MiniParser } from "mini-program-parser"; | ||
| Component({ | ||
@@ -26,20 +28,2 @@ options: { | ||
| parsedData(data) { | ||
| if (!data) return; | ||
| // 特殊处理表格标签 | ||
| if (data.length > 0) { | ||
| data.forEach((dataItem) => { | ||
| const { name, children } = dataItem; | ||
| if (name === "table" && children) { | ||
| const wrapper = children.filter((item) => | ||
| ["thead", "tbody"].includes(item.name) | ||
| ); | ||
| if (wrapper) { | ||
| dataItem.children = []; | ||
| wrapper.forEach((item) => { | ||
| dataItem.children = [...dataItem.children, ...item.children]; | ||
| }); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
| this.setData({ | ||
@@ -46,0 +30,0 @@ parserData: data, |
| { | ||
| "component": true, | ||
| "usingComponents": { | ||
| "render": "./index" | ||
| "render": "./index", | ||
| "tableRender": "../table-render/index" | ||
| } | ||
| } |
+1
-1
| { | ||
| "name": "mini-program-parser", | ||
| "version": "0.3.3", | ||
| "version": "0.3.4", | ||
| "scripts": { | ||
@@ -5,0 +5,0 @@ "dev": "rollup -c ./rollup.dev.config.js --watch", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
54327
1.45%29
16%1031
2.18%