https://github.com/skyfi/html2wxml
convert html to wxml.微信小程序html转wxml.
https://github.com/skyfi/html2wxml
Last synced: about 1 year ago
JSON representation
convert html to wxml.微信小程序html转wxml.
- Host: GitHub
- URL: https://github.com/skyfi/html2wxml
- Owner: skyFi
- Created: 2016-11-14T13:37:19.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-26T09:46:15.000Z (over 8 years ago)
- Last Synced: 2025-03-18T16:12:19.997Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 52
- Watchers: 2
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## 微信小程序,HTML转WXML。
更新:好消息,微信小程序在基础库 1.6.4 添加了 [web-view](https://mp.weixin.qq.com/debug/wxadoc/dev/component/web-view.html) 组件!
### usage:
[`npm install html2wxml --save`](https://www.npmjs.com/package/html2wxml)
或
1. 引入`src`里面`html2json.js/html2wxml.wxml/htmlparser.js/example.wxss`到工程`lib`目录下;
2. 在需要将html转wxml的地方按下添加代码;
`wxml`:
```html
```
`js`:
```javascript
'use strict';
import {html2json} from '../src/html2json';//按实际工程目录结构
Page({
data: {
innerHTML: html2json('
ab
c
'/*需要转的html*/).child
},
...
});
```
`wxss`:
```css
@import "../src/html2wxml.wxss";//按实际工程目录结构
```
#### TIP:
在`example.wxss`中,可自定义添加修改html标签对应的样式,以满足不同的需求,也欢迎提供全面的样式提交`pull request`。
标签列表:
```javascript
[
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'a',
'abbr',
'address',
'applet',
'acronym',
'area',
'article',
'aside',
'audio',
'b',
'base',
'basefont',
'bdi',
'bdo',
'big',
'blockquote',
'body',
'br',
'button',
'canvas',
'caption',
'center',
'cite',
'code',
'col',
'colgroup',
'command',
'datalist',
'dd',
'del',
'details',
'dfn',
'dir',
'div',
'dl',
'dt',
'em',
'embed',
'fieldset',
'figcaption',
'figure',
'font',
'footer',
'form',
'frame',
'frameset',
'h1',
'head',
'header',
'hgroup',
'hr',
'html',
'i',
'iframe',
'img',
'input',
'ins',
'keygen',
'kbd',
'label',
'legend',
'li',
'link',
'map',
'mark',
'menu',
'meta',
'meter',
'nav',
'noframes',
'noscript',
'object',
'ol',
'optgroup',
'option',
'output',
'p',
'param',
'pre',
'progress',
'q',
'rp',
'ruby',
's',
'samp',
'script',
'select',
'small',
'source',
'span',
'strike',
'strong',
'style',
'sub',
'summary',
'sup',
'table',
'tbody',
'td',
'textarea',
'tfoot',
'th',
'thead',
'time',
'title',
'tr',
'track',
'tt',
'u',
'ul',
'var',
'video',
'wbr',
'rt',
'section'
]
```