Top Related Projects
Quick Overview
mp-html is a powerful and flexible HTML parser for mini-programs and mobile apps. It supports rendering rich text content, including custom components and styles, across various platforms such as WeChat, Alipay, and Vue.js applications.
Pros
- Cross-platform compatibility (WeChat, Alipay, QQ, Baidu, Toutiao, uni-app, etc.)
- Extensive customization options for tags, styles, and components
- High performance with virtual DOM and lazy-loading
- Active development and community support
Cons
- Learning curve for advanced customizations
- Limited support for some complex HTML structures
- May require additional configuration for certain platforms
- Documentation primarily in Chinese, which may be challenging for non-Chinese speakers
Code Examples
- Basic usage in a WeChat mini-program:
<mp-html content="{{htmlContent}}" />
- Customizing styles:
<mp-html content="{{htmlContent}}" tag-style="{{tagStyle}}" />
Page({
data: {
htmlContent: '<div class="custom">Hello, World!</div>',
tagStyle: {
div: 'color: red; font-size: 18px;'
}
}
})
- Adding custom components:
<mp-html content="{{htmlContent}}" use-custom-components="{{true}}" />
Component({
properties: {
nodes: {
type: Array,
value: []
}
},
methods: {
tap() {
console.log('Custom component tapped')
}
}
})
Getting Started
-
Install the package:
npm install mp-html
-
Import and use in your mini-program:
// In your page.json { "usingComponents": { "mp-html": "mp-html" } } // In your page.wxml <mp-html content="{{htmlContent}}" /> // In your page.js Page({ data: { htmlContent: '<h1>Hello, mp-html!</h1>' } })
-
For more advanced usage and customization, refer to the official documentation.
Competitor Comparisons
A cross-platform framework using Vue.js
Pros of uni-app
- Comprehensive cross-platform development framework for multiple platforms (iOS, Android, Web, etc.)
- Large ecosystem with extensive plugins and components
- Supports Vue.js, providing a familiar development experience for Vue developers
Cons of uni-app
- Steeper learning curve due to its extensive feature set
- May have performance overhead for simpler projects
- Larger bundle size compared to more focused solutions
Code Comparison
mp-html (HTML parsing and rendering):
<mp-html content="{{htmlContent}}" />
uni-app (Vue component):
<template>
<view>
<text>{{ message }}</text>
</view>
</template>
<script>
export default {
data() {
return {
message: 'Hello, uni-app!'
}
}
}
</script>
mp-html is specifically designed for HTML parsing and rendering in mini-programs, while uni-app is a full-fledged cross-platform development framework. mp-html offers a simpler, more focused solution for HTML rendering, whereas uni-app provides a comprehensive toolset for building entire applications across multiple platforms. The choice between the two depends on the project's scope and requirements.
A lightweight, extendable front-end developer tool for mobile web page.
Pros of vConsole
- More comprehensive debugging tool with network, storage, and element inspection features
- Designed specifically for mobile web debugging, offering a better mobile-oriented experience
- Larger community and more frequent updates, backed by Tencent
Cons of vConsole
- Focused solely on debugging, not offering HTML rendering capabilities
- Heavier in terms of file size and resource usage compared to mp-html
- May require more setup and configuration for basic usage
Code Comparison
mp-html (HTML rendering):
<mp-html content="<div>Hello, World!</div>" />
vConsole (Debugging initialization):
import VConsole from 'vconsole';
const vConsole = new VConsole();
// vConsole is now initialized
Summary
While mp-html is primarily an HTML renderer for mini-programs, vConsole is a comprehensive debugging tool for mobile web development. vConsole offers more extensive debugging features but lacks HTML rendering capabilities. mp-html is lighter and more focused on its specific task of HTML rendering. The choice between the two depends on the primary need: debugging (vConsole) or HTML rendering (mp-html).
开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
Pros of Taro
- Cross-platform development: Supports multiple platforms including WeChat Mini Program, H5, React Native
- Large ecosystem: Extensive plugin system and community support
- Familiar React-like syntax: Easier adoption for React developers
Cons of Taro
- Steeper learning curve: More complex setup and configuration
- Larger bundle size: May impact performance on resource-constrained devices
- Potential compatibility issues: Some native features may require platform-specific code
Code Comparison
mp-html (WeChat Mini Program):
<mp-html content="{{htmlContent}}" />
Taro (React-like syntax):
import { RichText } from '@tarojs/components'
function MyComponent() {
return <RichText nodes={htmlContent} />
}
Key Differences
- mp-html is specifically designed for WeChat Mini Programs, while Taro aims for cross-platform development
- mp-html focuses on HTML rendering, whereas Taro provides a complete framework for building applications
- Taro offers more flexibility and features but comes with increased complexity compared to mp-html's simplicity
🦎 一套代码运行多端,一端所见即多端所见
Pros of Chameleon
- Cross-platform development framework supporting multiple platforms (Web, WeChat Mini Program, Alipay Mini Program, Baidu Smart Program, etc.)
- Unified development experience with a single codebase for multiple platforms
- Rich ecosystem with built-in UI components and plugins
Cons of Chameleon
- Steeper learning curve due to its comprehensive nature and custom syntax
- Less focused on specific HTML rendering capabilities
- May introduce overhead for simpler projects that don't require cross-platform support
Code Comparison
mp-html (HTML rendering in Mini Programs):
<mp-html content="{{htmlContent}}" />
Chameleon (Cross-platform component):
<template>
<view>
<text>{{ message }}</text>
</view>
</template>
Key Differences
- mp-html focuses specifically on HTML rendering in Mini Programs, while Chameleon is a full-fledged cross-platform development framework
- mp-html provides a simpler API for rendering HTML content, whereas Chameleon offers a more comprehensive set of tools for building entire applications
- Chameleon requires developers to use its custom syntax and components, while mp-html works with standard HTML content
Use Cases
- Choose mp-html for projects that primarily need HTML rendering capabilities in Mini Programs
- Opt for Chameleon when developing complex applications targeting multiple platforms from a single codebase
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
mp-html
ä¸ä¸ªå¼ºå¤§çå°ç¨åºå¯ææ¬ç»ä»¶
åè½ä»ç»
- æ¯æå¨å¤ä¸ªä¸»æµçå°ç¨åºå¹³å°å
uni-app
ä¸ä½¿ç¨ - æ¯æ丰å¯çæ ç¾ï¼å
æ¬
table
ãvideo
ãsvg
çï¼ - æ¯æ丰å¯çäºä»¶ææï¼èªå¨é¢è§å¾çãé¾æ¥å¤ççï¼
- æ¯æ设置å ä½å¾ï¼å è½½ä¸ãåºéæ¶ãé¢è§æ¶ï¼
- æ¯æéç¹è·³è½¬ãé¿æå¤å¶ç丰å¯åè½
- æ¯æ大é¨å html å®ä½
- 丰å¯çæ件ï¼å
³é®è¯æç´¢ãå
容ç¼è¾ã
latex
å ¬å¼çï¼ - æçé«ã容éæ§å¼ºä¸è½»éåï¼
â25KB
ï¼9KB gzipped
ï¼
æ¥ç åè½ä»ç» äºè§£æ´å¤
使ç¨æ¹æ³
åçå¹³å°
npm
æ¹å¼-
å¨é¡¹ç®ç®å½ä¸å®è£ ç»ä»¶å
npm install mp-html
-
å¼åè å·¥å ·ä¸å¾é
ä½¿ç¨ npm 模å
ï¼è¥æ²¡ææ¤é项åä¸éè¦ï¼å¹¶ç¹å»å·¥å · - æ建 npm
-
å¨éè¦ä½¿ç¨é¡µé¢ç
json
æ件ä¸æ·»å{ "usingComponents": { "mp-html": "mp-html" } }
-
å¨éè¦ä½¿ç¨é¡µé¢ç
wxml
æ件ä¸æ·»å<mp-html content="{{html}}" />
-
å¨éè¦ä½¿ç¨é¡µé¢ç
js
æ件ä¸æ·»åPage({ onLoad () { this.setData({ html: '<div>Hello World!</div>' }) } })
-
- æºç æ¹å¼
-
å°æºç ä¸å¯¹åºå¹³å°ç代ç å ï¼
dist/platform
ï¼æ·è´å°components
ç®å½ä¸ï¼æ´å为mp-html
-
å¨éè¦ä½¿ç¨é¡µé¢ç
json
æ件ä¸æ·»å{ "usingComponents": { "mp-html": "/components/mp-html/index" } }
-
æ¥ç å¿«éå¼å§ äºè§£æ´å¤
uni-app
-
æºç æ¹å¼
-
å°æºç ä¸
dist/uni-app
å çå 容æ·è´å°é¡¹ç®æ ¹ç®å½ä¸
å¯ä»¥ç´æ¥éè¿ æ件å¸åº å¼å ¥ -
å¨éè¦ä½¿ç¨é¡µé¢ç
vue
æ件ä¸æ·»å<template> <view> <mp-html :content="html" /> </view> </template> <script> import mpHtml from '@/components/mp-html/mp-html' export default { // HBuilderX 2.5.5+ å¯ä»¥éè¿ easycom èªå¨å¼å ¥ components: { mpHtml }, data () { return { html: '<div>Hello World!</div>' } } } </script>
-
-
npm
æ¹å¼-
å¨é¡¹ç®ç®å½ä¸å®è£ ç»ä»¶å
npm install mp-html
-
å¨éè¦ä½¿ç¨é¡µé¢ç
vue
æ件ä¸æ·»å<template> <view> <mp-html :content="html" /> </view> </template> <script> import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html' export default { // ä¸å¯çç¥ components: { mpHtml }, data () { return { html: '<div>Hello World!</div>' } } } </script>
使ç¨
cli
æ¹å¼è¿è¡ç项ç®ï¼éè¿npm
æ¹å¼å¼å ¥æ¶ï¼éè¦å¨vue.config.js
ä¸é ç½®transpileDependencies
ï¼è¯¦æ å¯è§ #330
å¦æå¨nvue
ä¸ä½¿ç¨è¿è¦å°dist/uni-app/static
ç®å½ä¸çå 容æ·è´å°é¡¹ç®çstatic
ç®å½ä¸ï¼å¦åæ æ³è¿è¡ -
æ¥ç å¿«éå¼å§ äºè§£æ´å¤
ç»ä»¶å±æ§
å±æ§ | ç±»å | é»è®¤å¼ | 说æ |
---|---|---|---|
container-style | String | 容å¨çæ ·å¼ï¼2.1.0+ï¼ | |
content | String | ç¨äºæ¸²æç html å符串 | |
copy-link | Boolean | true | æ¯å¦å 许å¤é¨é¾æ¥è¢«ç¹å»æ¶èªå¨å¤å¶ |
domain | String | 主ååï¼ç¨äºé¾æ¥æ¼æ¥ï¼ | |
error-img | String | å¾çåºéæ¶çå ä½å¾é¾æ¥ | |
lazy-load | Boolean | false | æ¯å¦å¼å¯å¾çæå è½½ |
loading-img | String | å¾çå è½½è¿ç¨ä¸çå ä½å¾é¾æ¥ | |
pause-video | Boolean | true | æ¯å¦å¨ææ¾ä¸ä¸ªè§é¢æ¶èªå¨æåå ¶ä»è§é¢ |
preview-img | Boolean | true | æ¯å¦å 许å¾ç被ç¹å»æ¶èªå¨é¢è§ |
scroll-table | Boolean | false | æ¯å¦ç»æ¯ä¸ªè¡¨æ ¼æ·»å ä¸ä¸ªæ»å¨å±ä½¿å ¶è½åç¬æ¨ªåæ»å¨ |
selectable | Boolean | false | æ¯å¦å¼å¯ææ¬é¿æå¤å¶ |
set-title | Boolean | true | æ¯å¦å° title æ ç¾çå 容设置å°é¡µé¢æ é¢ |
show-img-menu | Boolean | true | æ¯å¦å 许å¾ç被é¿ææ¶æ¾ç¤ºèå |
tag-style | Object | 设置æ ç¾çé»è®¤æ ·å¼ | |
use-anchor | Boolean | false | æ¯å¦ä½¿ç¨éç¹é¾æ¥ |
æ¥ç å±æ§ äºè§£æ´å¤
ç»ä»¶äºä»¶
å称 | 触åæ¶æº |
---|---|
load | dom æ å è½½å®æ¯æ¶ |
ready | å¾çå è½½å®æ¯æ¶ |
error | åç渲æéè¯¯æ¶ |
imgtap | å¾ç被ç¹å»æ¶ |
linktap | é¾æ¥è¢«ç¹å»æ¶ |
æ¥ç äºä»¶ äºè§£æ´å¤
api
ç»ä»¶å®ä¾ä¸æä¾äºä¸äº api
æ¹æ³å¯ä¾è°ç¨
å称 | ä½ç¨ |
---|---|
in | å°éç¹è·³è½¬çèå´éå®å¨ä¸ä¸ª scroll-view å |
navigateTo | éç¹è·³è½¬ |
getText | è·åææ¬å 容 |
getRect | è·åå¯ææ¬å 容çä½ç½®åå¤§å° |
setContent | 设置å¯ææ¬å 容 |
imgList | è·åææå¾ççæ°ç» |
pauseMedia | æåææ¾é³è§é¢ï¼2.2.2+ï¼ |
setPlaybackRate | 设置é³è§é¢ææ¾éçï¼2.4.0+ï¼ |
æ¥ç api äºè§£æ´å¤
æ件æ©å±
é¤åºæ¬åè½å¤ï¼æ¬ç»ä»¶è¿æä¾äºä¸°å¯çæ©å±ï¼å¯æç §éè¦éç¨
å称 | ä½ç¨ |
---|---|
audio | é³ä¹ææ¾å¨ |
editable | å¯ææ¬ç¼è¾ |
emoji | 解æ emoji |
highlight | 代ç åé«äº®æ¾ç¤º |
markdown | 渲æ markdown |
search | å ³é®è¯æç´¢ |
style | å¹é style æ ç¾ä¸çæ ·å¼ |
txv-video | 使ç¨è ¾è®¯è§é¢ |
img-cache | å¾çç¼å by @PentaTea |
latex | 渲æ latex å ¬å¼ by @Zeng-J |
card | å¡çå±ç¤º by @whoooami |
æ¥ç æ件 äºè§£æ´å¤
使ç¨æ¡ä¾
å®æ¹ç¤ºä¾ | 欢ååå | å¤ä¹çæ´» | é£æ³æ¥ | å¾®æ | å¤å ¸æå¦åèé 读 |
---|---|---|---|---|---|
ç§å¦å¤ä¹ | ç¨åºåææ¯ä¹æ | å ¸å ¸å客 | ä¼ç§ç¬è®° | 365 å·é¢ | ååå ±äº«ä¹¦ |
---|---|---|---|---|---|
ææ¯æº share | ä½ ç代ç åççæ£ | è°å¦ | å°è«åå°¼ | 模çæ¼ç¤º | AIç¦å |
---|---|---|---|---|---|
以ä¸æåä¸åå åï¼æ´å¤å¯è§ 使ç¨æ¡ä¾æ¶éï¼æ¬¢è¿æ·»å ï¼
许å¯ä¸æ¯æ
-
许å¯
æ¨å¯ä»¥å è´¹ç使ç¨ï¼å æ¬åç¨ï¼ãå¤å¶æä¿®æ¹æ¬ç»ä»¶ MIT License
å¨ç¨äºç产ç¯å¢åå¡å¿ ç»è¿å åæµè¯ï¼ç±æ件bug
带æ¥çæ失æ¦ä¸è´è´£ï¼å¯ä»¥èªè¡ä¿®æ¹æºç ï¼ -
èç³»
欢è¿å å ¥QQ
交æµç¾¤ï¼
群1ï¼å·²æ»¡ï¼ï¼699734691
群2ï¼å·²æ»¡ï¼ï¼778239129
群3ï¼960265313
-
æ¯æ
æ´æ°æ¥å¿
-
v2.5.0 (20240422)
U
play
äºä»¶å¢å è¿åsrc
çä¿¡æ¯ è¯¦ç»U
preview-img
å±æ§æ¯æ设置为all
å¼å¯base64
å¾çé¢è§ 详ç»U
editable
æ件å¢å ç®æ模å¼ï¼ç¹å»æåç´æ¥ç¼è¾ï¼U
latex
æ件æ¯æåçº§å ¬å¼ è¯¦ç»F
ä¿®å¤äºè¡¨æ ¼é¨åæ åµä¸èæ¯ä¸¢å¤±çé®é¢ 详ç»F
ä¿®å¤äºé¨åsvg
æ æ³æ¾ç¤ºçé®é¢ 详ç»F
ä¿®å¤äºuni-app
åh5
åapp
端é¨åæ åµä¸æ ·å¼æ æ³è¯å«çé®é¢ 详ç»F
ä¿®å¤äºlatex
æ件é¨åæ åµä¸æ¾ç¤ºä¸æ£ç¡®çé®é¢ 详ç»F
ä¿®å¤äºeditable
æä»¶è¡¨æ ¼æ æ³å é¤çé®é¢F
ä¿®å¤äºeditable
æ件uni-app
åvue3
h5
端ç¹å»å¾çæ¥éçé®é¢F
ä¿®å¤äºeditable
æ件uni-app
å ç¹å»è¡¨æ ¼æ²¡æèåæ çé®é¢
-
v2.4.3 (20240121)
A
å¢å card æ件 è¯¦ç» by @whoooamiF
ä¿®å¤äºsvg
ä¸å å«foreignobject
å¯è½ä¸æ¾ç¤ºçé®é¢ 详ç»F
ä¿®å¤äºå并åå æ ¼çè¡¨æ ¼é¨åæ åµä¸æ¾ç¤ºä¸æ£ç¡®çé®é¢ 详ç»F
ä¿®å¤äºimg
æ ç¾è®¾ç½®object-fit
æ æçé®é¢ 详ç»F
ä¿®å¤äºlatex
æä»¶å ¬å¼ä¼æ¢è¡çé®é¢ 详ç»F
ä¿®å¤äºuni-app
åeditable
åaudio
æä»¶å ±ç¨æ¶ç¹å»audio
æ æ³ç¼è¾çé®é¢ è¯¦ç» by @whoooamiF
ä¿®å¤äºæ¯ä»å®å°ç¨åºè®¾ç½®äºå®½é«çå¾çå¯è½æ¾ç¤ºä¸æ£å¸¸çé®é¢ 详ç»F
ä¿®å¤äºuni-app
å 微信å°ç¨åºé¨åæ åµä¸å¾çä¼æ¥éreplace of undefined
çé®é¢F
ä¿®å¤äºuni-app
å å¿«æå°ç¨åºå¾çä¸æ¾ç¤ºçé®é¢ 详ç»
ä»
1.x
çå级æ¹æ³å¯è§ æ´æ°æå
æ¥ç æ´æ°æ¥å¿ äºè§£æ´å¤
Top Related Projects
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot