微信小程序 WXML Parser
npm install -D @leejim/wxml-parser
var WXMLParser = require('@leejim/wxml-parser');
var parser = new WXMLParser({
onopentag(tagname, attrs, isSelfClosing) {},
onclosetag(tagname) {},
ontext(text) {},
oncomment(cmt) {},
ontemplate(tmp) {}
});
parser.write('<view>test</view>');
参数名 | 数据类型 | 描述 |
---|---|---|
tagname | string |
标签名 |
attrs | `Array<string | AttrEntity>; interface AttrEntity { key: string; value: string } ` |
isSelfClosing | boolean |
是否自闭合标签 |