@jiahuix/mini-html-parser2

0.1.6 • Public • Published

mini-html-parser2

forked from ant-mini-program/mini-html-parser,为了兼容Taro,将所有依赖包都打进一个文件,避免Taro.build时找不到require的文件

安装

$ npm install @jiahuix/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

Package Sidebar

Install

npm i @jiahuix/mini-html-parser2

Weekly Downloads

5

Version

0.1.6

License

none

Unpacked Size

35.1 kB

Total Files

3

Last publish

Collaborators

  • jiahuix