Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

ant-mini-program/mini-html-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mini-html-parser2

支付宝小程序基础库在 2.8.5 及之后版本已在 组件中内置 HTML 解析能力:https://opendocs.alipay.com/mini/component/rich-text

安装

$ 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

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •