mini-html-parser2
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

mini-html-parser2

安装

$ npm install mini-html-parser2 --save

使用

// page.js
const html = `<div>
<span>test</span>
<div>
    <span>table test</span>
    <table>
        <thead>
            <tr>
                <th>title</th>
                <th>title</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td colspan="2">yy</td>
                <td>xx</td>
                <td>xx</td>
                <td>xx</td>
            </tr>
        </tbody>
    </table>
</div>
</div>`
import parse from 'mini-html-parser2';

Page({
  data: {
    nodes: [],
  },
  onLoad() {
    parse(html, (err, nodes) => {
      if (!err) {
        this.setData({
          nodes,
        });
      }
    })
  },
})
<!-- page.axml -->
<rich-text nodes="{{nodes}}" />

运行测试

$ npm run build
$ npm test

Dependencies (3)

Dev Dependencies (3)

Package Sidebar

Install

npm i mini-html-parser2

Weekly Downloads

71

Version

0.3.0

License

none

Unpacked Size

44.2 kB

Total Files

10

Last publish

Collaborators

  • pingan1927
  • imsenyu
  • issac.lj