uniapp 使用towxml

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": {}
}

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值