# feimao-wx-parse

> 适用于 Mpvue 的微信小程序富文本解析自定义组件，支持HTML及markdown解析

Latest version **0.3.0-wx** (published 2019-08-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install feimao-wx-parse
pnpm add feimao-wx-parse
yarn add feimao-wx-parse
bun add feimao-wx-parse
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0-wx |
| Published | 2019-08-13 |
| First published | 2018-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 54.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 377 |
| Author | icindy |
| Maintainers | chenruixi |
| Keywords | mpvue, wxparse, wxapp |

## Links

- npm: https://www.npmjs.com/package/feimao-wx-parse
- Repository: https://github.com/F-loat/mpvue-wxParse
- Homepage: https://github.com/F-loat/mpvue-wxParse#readme
- Issues: https://github.com/F-loat/mpvue-wxParse/issues
- npm.io page: https://npm.io/package/feimao-wx-parse

## Recent versions

- 0.3.0-wx (latest) — 2019-08-13
- 0.2.0-alpay — 2019-07-31
- 0.2.0-publish — 2019-03-24
- 0.1.2 — 2019-03-13
- 0.1.1 — 2018-08-02
- 0.1.0 — 2018-05-27
- 0.0.4 — 2018-05-27
- 0.0.3 — 2018-05-27
- 0.0.2 — 2018-05-27
- 0.0.1 — 2018-05-27

## README

# mpvue-wxParse 适用于 Mpvue 的微信小程序富文本解析组件

> 支持 Html、Markdown 转 Wxml 可视化，修改自: [wxParse](https://github.com/icindy/wxParse)

[![npm package](https://img.shields.io/npm/v/mpvue-wxparse.svg)](https://npmjs.org/package/mpvue-wxparse)
[![npm downloads](http://img.shields.io/npm/dm/mpvue-wxparse.svg)](https://npmjs.org/package/mpvue-wxparse)


## 扫码体验
![小程序码](./static/qrcode.jpg)


## 属性

| 名称              | 类型           | 默认值        | 描述               |
| -----------------|--------------- | ------------- | ----------------  |
| content          | String         | —             | 渲染内容           |
| noData           | String         | 数据不能为空   | 空数据时的渲染展示  |
| startHandler     | Function       | null          | 自定义 parser 函数 |
| endHandler       | Function       | null          | 自定义 parser 函数 |
| charsHandler     | Function       | null          | 自定义 parser 函数 |
| image            | Object         | 见下文        | 图片相关参数        |

### 自定义 parser 函数具体介绍

* 传入的参数为当前节点的 `node` 对象
* 无需返回值，通过对 `node` 对象直接操作来完成需要的改动
* 自定义函数会在原解析函数处理之后执行

### image 对象具体属性

| 名称              | 类型           | 默认值        | 描述                |
| -----------------|--------------- | ------------- | ------------------ |
| mode             | String         | 'aspectFit'   | 图片裁剪、缩放的模式 |
| padding          | Number         | 0             | 图片内边距          |
| lazyLoad         | Boolean        | false         | 图片懒加载          |


## 基本使用方法

* 安装

``` bash
npm i mpvue-wxparse
```

* 使用

``` vue
<template>
  <div>
    <wxParse :content="article" />
  </div>
</template>

<script>
import wxParse from 'mpvue-wxparse'

export default {
  components: {
    wxParse
  },
  data () {
    return {
      article: '<div>我是HTML代码</div>'
    }
  }
}
</script>
```


## 渲染 Markdown

> 先将 markdown 转换为 html 即可

``` bash
npm install marked
```

``` js
import marked from 'marked'
import wxParse from 'mpvue-wxparse'

export default {
  components: {
    wxParse
  },
  data () {
    return {
      article: marked(`#hello, markdown!`)
    }
  }
}
```


## 常见问题

* 打包时出错 `ERROR in static/js/vendor.js from UglifyJs`

参照以下配置使 babel 处理 mpvue-wxparse，或直接关闭 UglifyJs 插件

``` js
// webpack.base.conf.js
{
  test: /\.js$/,
  include: [
    resolve('src'),
    resolve('node_modules/mpvue-wxparse')
  ],
  use: [
    'babel-loader',
    {
      loader: 'mpvue-loader',
      options: {
        checkMPEntry: true
      }
    }
  ]
}
```


## 感谢

[@stonewen](https://github.com/stonewen)| [@Daissmentii](https://github.com/Daissmentii)        | [@wuyanwen](https://github.com/wuyanwen)           | [@vcxiaohan](https://github.com/vcxiaohan)

---
_Source: https://npm.io/package/feimao-wx-parse · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
