npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mpvue-wxparse

v0.6.5

Published

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

Downloads

455

Readme

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

支持 Html、Markdown 转 Wxml 可视化,修改自: wxParse

npm package npm downloads

扫码体验

小程序码

属性

| 名称 | 类型 | 默认值 | 描述 | | -----------------|--------------- | ------------- | ---------------- | | loading | Boolean | false | 数据加载状态 | | className | String | — | 自定义 class 名称 | | content | String | — | 渲染内容 | | noData | String | 数据不能为空 | 空数据时的渲染展示 | | startHandler | Function | 见源码 | 自定义 parser 函数 | | endHandler | Function | null | 自定义 parser 函数 | | charsHandler | Function | null | 自定义 parser 函数 | | imageProp | Object | 见下文 | 图片相关参数 |

自定义 parser 函数具体介绍

  • 传入的参数为当前节点 node 对象及解析结果 results 对象,例如 startHandler(node, results)
  • 无需返回值,通过对传入的参数直接操作来完成需要的改动
  • 自定义函数会在原解析函数处理之后执行

imageProp 对象具体属性

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

事件

| 名称 | 参数 | 描述 | | -----------------|----------------- | ---------------- | | preview | 图片地址,原始事件 | 预览图片时触发 | | navigate | 链接地址,原始事件 | 点击链接时触发 |

基本使用方法

  • 安装
npm i mpvue-wxparse
  • 使用
<template>
  <div>
    <wxParse :content="article" @preview="preview" @navigate="navigate" />
  </div>
</template>

<script>
import wxParse from 'mpvue-wxparse'

export default {
  components: {
    wxParse
  },
  data () {
    return {
      article: '<div>我是HTML代码</div>'
    }
  },
  methods: {
    preview(src, e) {
      // do something
    },
    navigate(href, e) {
      // do something
    }
  }
}
</script>

<style>
@import url("~mpvue-wxparse/src/wxParse.css");
</style>

渲染 Markdown

先将 markdown 转换为 html 即可

npm install marked
import marked from 'marked'
import wxParse from 'mpvue-wxparse'

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

Tips

  • v0.6 之后的版本样式文件需自行引入

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

参照以下配置使 babel 处理 mpvue-wxparse,或更新 UglifyJs 插件

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

感谢

@stonewen| @Daissmentii | @wuyanwen | @vcxiaohan