Towxml 是一个可将HTML、Markdown转为微信小程序WXML(WeiXin Markup Language)的渲染库。用于解决在微信小程序中Markdown、HTML不能直接渲染的问题。

  1. 克隆项目到本地
git clone https://github.com/sbfkcel/towxml.git
  1. 构建依赖
npm install
  1. 本地打包
npm run build
  1. 拷贝dist到项目中,重命名
    在这里插入图片描述

  2. 修改 decode.json
    路径修改为相对路径

{
  "component": true,
  "usingComponents": {
    "decode": "./decode",
    "audio-player": "./audio-player/audio-player",
    "echarts": "./echarts/echarts",
    "latex": "./latex/latex",
    "table": "./table/table",
    "todogroup": "./todogroup/todogroup",
    "yuml": "./yuml/yuml",
    "img": "./img/img"
  }
}

使用
在 pages.json 中进行组件注册
如果单个页面使用

{
	"pages": [

		{
			"path": "pages/detail/detail",
			"style": {
				"navigationBarTitleText": "详情",
				"disableScroll": true,
				"app-plus": {
					"softinputMode": "adjustResize"
				},
				// 如果是单个页面使用
				// #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-QQ
				// "usingComponents": {
					// "towxml": "/wxcomponents/towxml/towxml"
				// }
				// #endif
			}
		},
	],
	"globalStyle": {
		"navigationBarTextStyle": "black",
		"navigationBarTitleText": "uni-app",
		"navigationBarBackgroundColor": "#F8F8F8",
		"backgroundColor": "#F8F8F8",
		// 如果是组件使用
		// #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-QQ
		"usingComponents": {
			"towxml": "/wxcomponents/towxml/towxml"
		}
		// #endif
	},
	"uniIdRouter": {}
}

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐