Top Related Projects
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
The library for web and native user interfaces.
Deliver web apps with confidence 🚀
Cybernetically enhanced web apps
A framework for building Mobile cross-platform UI
开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
Quick Overview
Mpx is a cross-platform development framework for building miniapps. It supports multiple platforms including WeChat, Alipay, Baidu, and web browsers, allowing developers to write once and deploy to various platforms. Mpx aims to enhance development efficiency and code reusability in the miniapp ecosystem.
Pros
- Cross-platform compatibility, supporting multiple miniapp platforms and web browsers
- Enhanced development experience with TypeScript support and Vue-like syntax
- Rich ecosystem with built-in components and plugins
- Efficient compilation and optimization for better performance
Cons
- Learning curve for developers new to the framework
- Limited community support compared to more established frameworks
- Potential overhead for simple projects that don't require cross-platform functionality
- Dependency on the maintainer (DiDi) for updates and long-term support
Code Examples
- Creating a simple component:
<template>
<view>{{message}}</view>
</template>
<script>
import { createComponent } from '@mpxjs/core'
createComponent({
data: {
message: 'Hello Mpx!'
}
})
</script>
- Using computed properties:
<template>
<view>{{reversedMessage}}</view>
</template>
<script>
import { createComponent } from '@mpxjs/core'
createComponent({
data: {
message: 'Hello Mpx!'
},
computed: {
reversedMessage() {
return this.message.split('').reverse().join('')
}
}
})
</script>
- Handling events:
<template>
<button bindtap="handleClick">Click me</button>
</template>
<script>
import { createComponent } from '@mpxjs/core'
createComponent({
methods: {
handleClick() {
console.log('Button clicked!')
}
}
})
</script>
Getting Started
- Install Mpx CLI:
npm install -g @mpxjs/cli
- Create a new Mpx project:
mpx create my-project
cd my-project
- Install dependencies and start development:
npm install
npm run serve
- Build for production:
npm run build
Competitor Comparisons
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
Pros of Vue
- Larger ecosystem and community support
- More comprehensive documentation and learning resources
- Wider adoption in web development projects
Cons of Vue
- Steeper learning curve for beginners
- Potentially more complex setup for small projects
- Less focused on cross-platform development
Code Comparison
Vue:
<template>
<div>{{ message }}</div>
</template>
<script>
export default {
data() {
return {
message: 'Hello Vue!'
}
}
}
</script>
Mpx:
<template>
<view>{{message}}</view>
</template>
<script>
import { createPage } from '@mpxjs/core'
createPage({
data: {
message: 'Hello Mpx!'
}
})
</script>
Key Differences
- Vue is primarily designed for web applications, while Mpx focuses on cross-platform mini-program development
- Mpx uses a syntax similar to Vue but with adaptations for mini-program environments
- Vue has a more extensive set of built-in directives and features compared to Mpx
Use Cases
- Choose Vue for complex web applications with a need for extensive ecosystem support
- Opt for Mpx when developing mini-programs for platforms like WeChat or Alipay
The library for web and native user interfaces.
Pros of React
- Larger ecosystem and community support
- More mature and battle-tested in production environments
- Extensive documentation and learning resources
Cons of React
- Steeper learning curve for beginners
- Requires additional libraries for state management and routing
- Larger bundle size compared to Mpx
Code Comparison
React component:
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
Mpx component:
<template>
<view>Hello, {{name}}</view>
</template>
<script>
import { createComponent } from '@mpxjs/core'
createComponent({
properties: {
name: String
}
})
</script>
Key Differences
- React uses JSX syntax, while Mpx uses a template-based approach similar to Vue.js
- Mpx is specifically designed for mini-program development, while React is a general-purpose library
- React has a more flexible component structure, whereas Mpx follows a more opinionated structure
Use Cases
- Choose React for large-scale web applications with complex UI requirements
- Opt for Mpx when developing mini-programs for platforms like WeChat or Alipay
Performance Considerations
- React's virtual DOM can provide better performance for complex UIs with frequent updates
- Mpx's lightweight nature may offer better initial load times for simpler applications
Deliver web apps with confidence 🚀
Pros of Angular
- Comprehensive framework with a full ecosystem of tools and libraries
- Strong TypeScript support and dependency injection system
- Large community and extensive documentation
Cons of Angular
- Steeper learning curve due to its complexity
- Heavier bundle size compared to lighter frameworks
- More opinionated, which may limit flexibility in some cases
Code Comparison
Angular component:
@Component({
selector: 'app-root',
template: '<h1>{{title}}</h1>'
})
export class AppComponent {
title = 'Hello, Angular!';
}
Mpx component:
createComponent({
template: '<view>{{message}}</view>',
data: {
message: 'Hello, Mpx!'
}
})
Key Differences
- Angular is a full-featured framework for web applications, while Mpx focuses on mini-program development
- Angular uses TypeScript by default, whereas Mpx primarily uses JavaScript
- Angular has a more complex architecture with modules, services, and dependency injection, while Mpx has a simpler component-based structure
- Mpx is specifically designed for cross-platform mini-program development, making it more suitable for that use case
Both frameworks have their strengths, with Angular being more suitable for large-scale web applications and Mpx excelling in mini-program development across multiple platforms.
Cybernetically enhanced web apps
Pros of Svelte
- Smaller bundle sizes due to compile-time optimization
- Simpler, more intuitive syntax with less boilerplate
- Built-in state management without additional libraries
Cons of Svelte
- Smaller ecosystem and community compared to more established frameworks
- Limited tooling and IDE support
- Steeper learning curve for developers coming from traditional frameworks
Code Comparison
Svelte component:
<script>
let count = 0;
function increment() {
count += 1;
}
</script>
<button on:click={increment}>
Clicks: {count}
</button>
Mpx component:
<template>
<button bindtap="increment">
Clicks: {{count}}
</button>
</template>
<script>
import { createComponent } from '@mpxjs/core'
createComponent({
data: {
count: 0
},
methods: {
increment() {
this.count++
}
}
})
</script>
Summary
Svelte offers a more modern approach to web development with its compile-time optimizations and simpler syntax. However, Mpx provides better support for multi-platform development, especially for WeChat mini-programs. The choice between the two depends on the specific project requirements and target platforms.
A framework for building Mobile cross-platform UI
Pros of Weex
- Cross-platform development: Supports iOS, Android, and web
- Mature ecosystem with extensive documentation and community support
- High performance due to native rendering
Cons of Weex
- Steeper learning curve for developers new to cross-platform development
- Larger app size compared to native solutions
- Less frequent updates and maintenance in recent years
Code Comparison
Weex (Vue-like syntax):
<template>
<div>
<text>{{ message }}</text>
</div>
</template>
<script>
export default {
data() {
return { message: 'Hello, Weex!' }
}
}
</script>
Mpx (Similar to Vue, but with some differences):
<template>
<view>
<text>{{ message }}</text>
</view>
</template>
<script>
import { createPage } from '@mpxjs/core'
createPage({
data: { message: 'Hello, Mpx!' }
})
</script>
Key Differences
- Weex focuses on cross-platform development, while Mpx is primarily for mini-programs
- Weex uses a more Vue-like syntax, whereas Mpx has some unique features for mini-program development
- Mpx has better integration with WeChat mini-program ecosystem
- Weex offers native rendering capabilities, while Mpx relies on the mini-program runtime
Both frameworks aim to simplify development processes, but they target different use cases and platforms.
开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
Pros of Taro
- Supports multiple platforms including React Native, H5, and various mini-programs
- Larger community and more frequent updates
- Extensive plugin system for extending functionality
Cons of Taro
- Steeper learning curve, especially for developers new to React
- Potentially larger bundle size due to cross-platform support
- May have performance overhead in some scenarios
Code Comparison
Taro (React-based):
import { Component } from 'react'
import { View, Text } from '@tarojs/components'
export default class Index extends Component {
render () {
return (
<View>
<Text>Hello, World!</Text>
</View>
)
}
}
Mpx (Vue-like syntax):
<template>
<view>
<text>Hello, World!</text>
</view>
</template>
<script>
import { createPage } from '@mpxjs/core'
createPage({})
</script>
Both Taro and Mpx are frameworks for developing mini-programs and cross-platform applications. Taro offers broader platform support and a larger ecosystem, while Mpx provides a more familiar Vue-like development experience with potentially easier optimization for WeChat mini-programs. The choice between them often depends on the specific project requirements, target platforms, and the development team's expertise.
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
Mpx, ä¸æ¬¾å ·æä¼ç§å¼åä½éªå深度æ§è½ä¼åçå¢å¼ºå跨端å°ç¨åºæ¡æ¶ã
å®ç½åææ¡£
欢è¿è®¿é®https://mpxjs.cnï¼è·éæ们æä¾çææ¡£æå使ç¨Mpxè¿è¡è·¨ç«¯å°ç¨åºå¼åã
è¿ææ´æ°
åºäº Mpx ç移å¨ç«¯åºç¡ç»ä»¶åº mpx-cube-ui å·²ç»å¼æºï¼æ´å¤è¯¦æ æ¥çè¿éã
Mpx 2.9 çæ¬æ£å¼åå¸ï¼æ¯æååç±»ãSSRåæ建产ç©ä½ç§¯ä¼åï¼æ´å¤è¯¦æ æ¥çè¿éï¼è¿ç§»æåæ¥çè¿éï¼ç¸å ³æåå API åèæ档已æ´æ°ã
ç®ä»
Mpxæ¯ä¸æ¬¾è´åäºæåå°ç¨åºå¼åä½éªåç¨æ·ä½éªçå¢å¼ºåå°ç¨åºè·¨ç«¯æ¡æ¶ï¼éè¿Mpxï¼æ们è½å¤ä»¥ç±»Vueçå¼åä½éªé«æä¼é å°æçåºé«æ§è½è·¨ç«¯å°ç¨åºåºç¨ï¼å¨ææå¼æ¾çå°ç¨åºå¹³å°åwebå¹³å°ä¸è¿è¡ã
Mpxå ·æ以ä¸åè½ç¹æ§ï¼
- æ°æ®ååº (èµå¼ååº / watch / computed)
- ç»åå¼ API
- å¢å¼ºæ¨¡æ¿è¯æ³ (å¨æç»ä»¶ / æ ·å¼ç»å® / ç±»åç»å® / å èäºä»¶å½æ° / ååç»å® / refs)
- æè´æ§è½ (è¿è¡æ¶æ§è½ä¼å / å ä½ç§¯ä¼å / æ¡æ¶è¿è¡æ¶ä½ç§¯14KB)
- é«æ强大çç¼è¯æ建 (åºäºwebpack5 / æ¯ææä¹ åç¼å / å ¼å®¹webpackçæ / å ¼å®¹åçå°ç¨åº / å®åæ¯ænpmåºæ¯ä¸çåå è¾åº / é«æè°è¯)
- åæ件ç»ä»¶å¼å
- æ¸è¿æ¥å ¥ / åçç»ä»¶æ¯æ
- ç¶æ管ç (Vuexè§è / æ¯æå¤å®ä¾Store)
- è·¨å¢éå¼å (packages)
- é»è¾å¤ç¨ (mixins)
- å¨è¾¹è½å (fetch / apiå¢å¼º / mock / webview-bridge)
- èææ¶æ¯æ
- å¤å¹³å°å¢å¼º (æ¯æå¨å¾®ä¿¡ãæ¯ä»å®ãç¾åº¦ãqqã头æ¡å°ç¨åºå¹³å°ä¸è¿è¡å¢å¼ºå¼å)
- 跨平å°ç¼è¯ (ä¸å¥ä»£ç 跨端è¾åºå°å¾®ä¿¡ãæ¯ä»å®ãç¾åº¦ãåèãQQã京ä¸ãå¿«åºç¨(web) å webå¹³å° ä¸è¿è¡)
- TypeScriptæ¯æ (åºäºThisTypeå®ç°äºå®åçç±»åæ¨å¯¼)
- I18nå½é å
- åå æµè¯
- E2Eæµè¯
- ååç±»
- SSR
- è¿è¡æ¶æ¸²ææ¹æ¡
- 跨端è¾åºRNï¼å³å°å°æ¥ï¼
å¿«éå¼å§
# å®è£
mpxèææ¶å·¥å
·
npm i -g @mpxjs/cli
# åå§å项ç®
mpx create mpx-project
# è¿å
¥é¡¹ç®ç®å½
cd mpx-project
# å®è£
ä¾èµ
npm i
# development
npm run serve
# production
npm run build
使ç¨å°ç¨åºå¼åè å·¥å ·æå¼é¡¹ç®æ件夹ä¸distä¸å¯¹åºå¹³å°çæ件夹å³å¯é¢è§ææã
使ç¨ç¤ºä¾
<template>
<!--å¨ææ ·å¼-->
<view class="container" wx:style="{{dynamicStyle}}">
<!--æ°æ®ç»å®-->
<view class="title">{{title}}</view>
<!--计ç®å±æ§æ°æ®ç»å®-->
<view class="title">{{reversedTitle}}</view>
<view class="list">
<!--循ç¯æ¸²æï¼å¨æç±»åï¼äºä»¶å¤çå
èä¼ å-->
<view wx:for="{{list}}" wx:key="id" class="list-item" wx:class="{{ {active:item.active} }}"
bindtap="handleTap(index)">
<view>{{item.content}}</view>
<!--循ç¯å
é¨ååæ°æ®ç»å®-->
<input type="text" wx:model="{{list[index].content}}"/>
</view>
</view>
<!--èªå®ä¹ç»ä»¶è·åå®ä¾ï¼ååç»å®ï¼èªå®ä¹ååç»å®å±æ§åäºä»¶-->
<custom-input wx:ref="ci" wx:model="{{customInfo}}" wx:model-prop="info" wx:model-event="change"/>
<!--å¨æç»ä»¶ï¼isä¼ å
¥ç»ä»¶åå符串ï¼å¯ä½¿ç¨çç»ä»¶éè¦å¨jsonä¸æ³¨åï¼å
¨å±æ³¨åä¹çæ-->
<component is="{{current}}"></component>
<!--æ¾ç¤º/éèdom-->
<view class="bottom" wx:show="{{showBottom}}">
<!--模æ¿æ¡ä»¶ç¼è¯ï¼__mpx_mode__为æ¡æ¶æ³¨å
¥çç¯å¢åéï¼æ¡ä»¶å¤æ为falseç模æ¿ä¸ä¼çæå°dist-->
<view wx:if="{{__mpx_mode__ === 'wx'}}">wx env</view>
<view wx:if="{{__mpx_mode__ === 'ali'}}">ali env</view>
</view>
</view>
</template>
<script>
import { createPage } from '@mpxjs/core'
createPage({
data: {
// å¨ææ ·å¼åç±»åä¹å¯ä»¥ä½¿ç¨computedè¿å
dynamicStyle: {
fontSize: '16px',
color: 'red'
},
title: 'hello world',
list: [
{
content: 'å
¨ååºå»',
id: 0,
active: false
},
{
content: 'ç¥çåè²ï¼å«æµª',
id: 1,
active: false
}
],
customInfo: {
title: 'test',
content: 'test content'
},
current: 'com-a',
showBottom: false
},
computed: {
reversedTitle () {
return this.title.split('').reverse().join('')
}
},
watch: {
title: {
handler (val, oldVal) {
console.log(val, oldVal)
},
immediate: true
}
},
handleTap (index) {
// å¤çå½æ°ç´æ¥éè¿åæ°è·åå½åç¹å»çindexï¼æ¸
æ°ç®æ´.
this.list[index].active = !this.list[index].active
},
onReady () {
setTimeout(() => {
// æ´æ°æ°æ®ï¼åæ¶å
³èç计ç®å±æ§reversedTitleä¹ä¼æ´æ°
this.title = 'ä½ å¥½ï¼ä¸ç'
// æ¤æ¶å¨æç»ä»¶ä¼ä»com-aåæ¢ä¸ºcom-b
this.current = 'com-b'
}, 1000)
}
})
</script>
<script type="application/json">
{
"usingComponents": {
"custom-input": "../components/custom-input",
"com-a": "../components/com-a",
"com-b": "../components/com-b"
}
}
</script>
<style lang="stylus">
.container
position absolute
width 100%
</style>
æ´å¤ç¤ºä¾è¯·æ¥çå®æ¹ç¤ºä¾é¡¹ç®
设计æè·¯
Mpxçæ ¸å¿è®¾è®¡æ路为å¢å¼ºï¼ä¸åäºä¸å 大é¨åå°ç¨åºæ¡æ¶å°web MVVMæ¡æ¶è¿ç§»å°å°ç¨åºä¸è¿è¡çåæ³ï¼Mpx以å°ç¨åºåççè¯æ³åææ¯è½å为åºç¡ï¼åé´åèäºä¸»æµçwebææ¯è®¾è®¡å¯¹å ¶è¿è¡äºæ©å±ä¸å¢å¼ºï¼å¹¶å¨æ¤ææ¯ä¸å®ç°äºä»¥å¾®ä¿¡å¢å¼ºè¯æ³ä¸ºbaseçåæ跨平å°è¾åºï¼è¯¥è®¾è®¡å¸¦æ¥ç好å¤å¦ä¸ï¼
- è¯å¥½çå¼åä½éªï¼å¨æ¹ä¾¿ä½¿ç¨æ¡æ¶æä¾ç便æ·ç¹æ§çåæ¶ï¼ä¹è½äº«åå°åª²ç¾åçå¼åçç¡®å®æ§å稳å®æ§ï¼å®å
¨æ²¡æ
æ¡æ¶å¤ªå¤åï¼ä¸å¦ç¨åç
ç顾èï¼ä¸ç®¡æ¯å¢å¼ºè¾åºè¿æ¯è·¨å¹³å°è¾åºï¼æç»çdist代ç å¯è¯»æ§æ强ï¼ä¾¿äºè°è¯ææ¥ï¼ - æè´çæ§è½ï¼å¾çäºå¢å¼ºç设计æè·¯ï¼Mpxæ¡æ¶å¨è¿è¡æ¶ä¸éè¦å太å¤å°è£ æ¹å¹³è½¬æ¢çå·¥ä½ï¼æ¡æ¶çè¿è¡æ¶é¨åæ为轻éç®æ´ï¼å缩+gzipåä» å ç¨14KBï¼é åç¼è¯æ建è¿è¡çå ä½ç§¯ä¼åååºäºæ¨¡æ¿æ¸²æå½æ°è¿è¡çæ°æ®ä¾èµè·è¸ªï¼Mpxæ¡æ¶å¨æ§è½æ¹é¢åå°äºä¸å æä¼(å°ç¨åºæ¡æ¶è¿è¡æ¶æ§è½è¯æµæ¥å)ï¼
- å®æ´çåçå ¼å®¹ï¼åæ ·å¾çäºå¢å¼ºç设计æè·¯ï¼Mpxæ¡æ¶è½å¤å®æ´å°å ¼å®¹å°ç¨åºåçææ¯è§èï¼å¹¶ä¸åå°å®æ¶è·è¿ãå¨Mpx项ç®ä¸å¼åè å¯ä»¥æ¹ä¾¿å°ä½¿ç¨ä¸å å·²æçå°ç¨åºçæï¼å¦ç»ä»¶åºãç»è®¡å·¥å ·çï¼åçå¼åè 们å¯ä»¥æ¹ä¾¿å°è¿è¡æ¸è¿è¿ç§»ï¼çè³å¯ä»¥å°æ¡æ¶ç跨平å°ç¼è¯è½ååºç¨å¨å¾®ä¿¡çåçå°ç¨åºç»ä»¶å½ä¸è¿è¡è·¨å¹³å°è¾åºã
çæå¨è¾¹
å¼åå¢é
æ ¸å¿å¢é: hiyuki, Blackgan3, anotherso1a, CommanderXL, yandadaFreedom, wangxiaokou, OnlyProbie, pagnkelly, thuman, theniceangel, dolymood
å¤é¨è´¡ç®è ï¼sky-admin, pkingwa, httpsxiao, lsycxyj, okxiaoliang4, tangminFE, codepan, zqjimlove, xuehebinglan, zhaoyiming0803, ctxrr, JanssenZhang, heiye9, lj0812, SuperHuangXu, twtylkmrh, NineSwordsMonster
æåæ¡ä¾
微信å°ç¨åº
æ»´æ»´åºè¡ | åºè¡å¹¿åº | æ»´æ»´å ¬äº¤ | æ»´æ»´éè | æ»´æ»´å¤å | å¸æºæå | å°æ¡å æ²¹ |
å½æè±è¯ | çªè¯åé | ç«æ¥æ¥åºç¨ | å°æ¡å »è½¦ | å¦èæç´æ课 | å°ç´å¯è课 | ç§åä¹¦åº |
å¨æ¦é¢ | ä¸è¡ç»³Lite | å¦èæä¼é课 | é£äº«ä¼ | ééå®å ¨å»ç | ééå®å ¨å¹è® | è§ç©¹äºæºæ¢° |
åºæçæé | è±å°çªæ车 | æ©å¿ä¼é | å°äºæ¼é | 顺é«å®æ¹å¾®åå | åååºè¡ | æ±è¡éPro |
交å | éæ¡å车 | 滴滴顺é£è½¦ | 滴滴代驾 | æ°æ¡ä»£é©¾ | æ è´ç¥é³ |
å ¶ä»å¹³å°å°ç¨åºï¼
æ»´æ»´åºè¡(æ¯ä»å®) | å°æ¡å çµ(æ¯ä»å®) | å¯åä¼(QQ) | å£è¢è¯ä»¶ç §(ç¾åº¦) | å¯åä¼(ç¾åº¦) | å¯åä¼(åè) |
æ´å¤æ¡ä¾ï¼è¥ä½ ä¹å¨ä½¿ç¨Mpxæ¡æ¶å¼åå°ç¨åºï¼å¹¶æ³å享ç»å¤§å®¶ï¼è¯·å¡«å¨æ¤issueä¸ã
交æµ
æä¾ å¾®ä¿¡ç¾¤ / QQ群 两ç§äº¤æµæ¹å¼
æ·»å MPXå ¥ç¾¤å°å©æçå¾ åéå ¥ç¾¤
æ«ç è¿å ¥QQ群
å¾çå githubç½ç»é®é¢å¯¼è´ä¸å¯è§çæåå¯ä»¥ç¹å»è¯¥é¾æ¥ï¼https://s.didi.cn/rod
Top Related Projects
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
The library for web and native user interfaces.
Deliver web apps with confidence 🚀
Cybernetically enhanced web apps
A framework for building Mobile cross-platform UI
开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
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