Convert Figma logo to code with AI

didi logompx

Mpx,一款具有优秀开发体验和深度性能优化的增强型跨端小程序框架

3,581
376
3,581
36

Top Related Projects

207,677

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

227,213

The library for web and native user interfaces.

95,657

Deliver web apps with confidence 🚀

78,194

Cybernetically enhanced web apps

18,267

A framework for building Mobile cross-platform UI

35,461

开放式跨端跨框架解决方案,支持使用 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

  1. Creating a simple component:
<template>
  <view>{{message}}</view>
</template>

<script>
import { createComponent } from '@mpxjs/core'

createComponent({
  data: {
    message: 'Hello Mpx!'
  }
})
</script>
  1. 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>
  1. 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

  1. Install Mpx CLI:
npm install -g @mpxjs/cli
  1. Create a new Mpx project:
mpx create my-project
cd my-project
  1. Install dependencies and start development:
npm install
npm run serve
  1. Build for production:
npm run build

Competitor Comparisons

207,677

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
227,213

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
95,657

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.

78,194

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.

18,267

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.

35,461

开放式跨端跨框架解决方案,支持使用 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 Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

mpx-logo

Mpx, 一款具有优秀开发体验和深度性能优化的增强型跨端小程序框架。

test-status docs-status

官网及文档

欢迎访问https://mpxjs.cn,跟随我们提供的文档指南使用Mpx进行跨端小程序开发。

近期更新

基于 Mpx 的移动端基础组件库 mpx-cube-ui 已经开源,更多详情查看这里。

Mpx 2.9 版本正式发布,支持原子类、SSR和构建产物体积优化,更多详情查看这里,迁移指南查看这里,相关指南及 API 参考文档已更新。

简介

Mpx是一款致力于提升小程序开发体验和用户体验的增强型小程序跨端框架,通过Mpx,我们能够以类Vue的开发体验高效优雅地构筑出高性能跨端小程序应用,在所有开放的小程序平台及web平台中运行。

Mpx具有以下功能特性:

快速开始

# 安装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项目中开发者可以方便地使用业内已有的小程序生态,如组件库、统计工具等;原生开发者们可以方便地进行渐进迁移;甚至可以将框架的跨平台编译能力应用在微信的原生小程序组件当中进行跨平台输出。

生态周边

包名版本描述
@mpxjs/corenpm versionmpx运行时核心
@mpxjs/webpack-pluginnpm versionmpx编译核心
@mpxjs/api-proxynpm version将各个平台的 api 进行转换,也可以将 api 转为 promise 格式
@mpxjs/storenpm versionç±»vuex store
@mpxjs/pinianpm versionmpx pinia store
@mpxjs/fetchnpm versionmpx网络请求库,处理wx并发请求限制
@mpxjs/unocss-pluginnpm versionmpx unocss插件,支持使用unocss原子类
@mpxjs/unocss-basenpm versionmpx unocss预设
@mpxjs/clinpm versionmpx脚手架命令行工具
@mpxjs/webview-bridgenpm version为跨小程序平台的H5项目提供通用的webview-bridge
@mpxjs/utilsnpm versionmpx运行时工具库
@mpxjs/babel-plugin-inject-page-eventsnpm version组合式API页面事件处理插件
@mpxjs/mpx-cube-uinpm version基于 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学而思优选课食享会青铜安全医生青铜安全培训视穹云机械
在武院三股绳Lite学而思优选课食享会青铜安全医生青铜安全培训视穹云机械
店有生意通花小猪打车橙心优选小二押镖顺鑫官方微商城嘀嗒出行汉行通Pro
店有生意通花小猪打车橙心优选小二押镖顺鑫官方微商城嘀嗒出行汉行通Pro
交圈青桔单车滴滴顺风车滴滴代驾新桔代驾标贝知音
交圈青桔单车滴滴顺风车滴滴代驾新桔代驾标贝知音

其他平台小程序:

滴滴出行(支付宝)小桔充电(支付宝)唯品会QQ口袋证件照(百度)唯品会(百度)唯品会(字节)
滴滴出行(支付宝)小桔充电(支付宝)唯品会(QQ)口袋证件照(百度)唯品会(百度)唯品会(字节)

更多案例,若你也在使用Mpx框架开发小程序,并想分享给大家,请填在此issue中。

交流

提供 微信群 / QQ群 两种交流方式

添加MPX入群小助手等待受邀入群

微信

扫码进入QQ群

QQ

图片因github网络问题导致不可见的朋友可以点击该链接:https://s.didi.cn/rod

NPM DownloadsLast 30 Days