Convert Figma logo to code with AI

wechat-miniprogram logominiprogram-demo

微信小程序组件 / API / 云开发示例

6,867
2,175
6,867
98

Top Related Projects

15,199

A UI library by WeChat official design team, includes the most useful widgets/modules.

微信小程序开发资源汇总 :100:

微信小程序商城,微信小程序微店

36,420

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/

轻量、可靠的小程序 UI 组件库

腾讯云开发云原生一体化部署工具 🚀 CloudBase Framework:一键部署,不限框架语言,云端一体化开发,基于Serverless 架构。A front-end and back-end integrated deployment tool. One-click deploy to serverless architecture. https://docs.cloudbase.net/framework/index

Quick Overview

The wechat-miniprogram/miniprogram-demo repository is an official demo project for WeChat Mini Programs. It showcases various features and components available in the WeChat Mini Program development framework, providing developers with practical examples and best practices for building mini programs.

Pros

  • Comprehensive showcase of WeChat Mini Program features and components
  • Official repository maintained by the WeChat team, ensuring up-to-date and reliable examples
  • Well-structured codebase with clear organization of different components and functionalities
  • Includes examples for both basic and advanced features, catering to developers of all skill levels

Cons

  • Limited documentation in English, which may be challenging for non-Chinese speaking developers
  • Some examples might be specific to the Chinese market and may not be directly applicable to global use cases
  • The repository is primarily for demonstration purposes and may not be suitable for direct use in production environments
  • Frequent updates may require developers to regularly check for changes and adapt their own projects accordingly

Code Examples

  1. Using the wx.request API to make network requests:
wx.request({
  url: 'https://api.example.com/data',
  method: 'GET',
  success: (res) => {
    console.log('Request successful:', res.data)
  },
  fail: (err) => {
    console.error('Request failed:', err)
  }
})
  1. Implementing a custom component:
Component({
  properties: {
    title: String,
    content: String
  },
  methods: {
    onTap() {
      this.triggerEvent('customEvent', { data: 'Some data' })
    }
  }
})
  1. Using the wx.navigateTo API for navigation:
wx.navigateTo({
  url: '/pages/detail/detail?id=123',
  success: (res) => {
    console.log('Navigation successful')
  },
  fail: (err) => {
    console.error('Navigation failed:', err)
  }
})

Getting Started

To get started with the WeChat Mini Program demo:

  1. Clone the repository:

    git clone https://github.com/wechat-miniprogram/miniprogram-demo.git
    
  2. Open the WeChat Developer Tools and import the project.

  3. Explore the different examples in the project structure.

  4. Run and test the mini program in the WeChat Developer Tools simulator.

  5. Refer to the official WeChat Mini Program documentation for detailed explanations of the components and APIs used in the demo.

Competitor Comparisons

15,199

A UI library by WeChat official design team, includes the most useful widgets/modules.

Pros of weui-wxss

  • Focuses specifically on UI components, providing a comprehensive set of WeChat-style elements
  • Offers a more lightweight and flexible solution for developers who only need UI components
  • Provides a consistent and native-looking WeChat interface design

Cons of weui-wxss

  • Limited to UI components, lacking full-fledged demo applications and complex functionality examples
  • May require more effort to integrate with other WeChat Mini Program features and APIs
  • Less suitable for developers looking for complete application examples and best practices

Code Comparison

miniprogram-demo:

Page({
  data: {
    list: []
  },
  onLoad: function() {
    this.loadData();
  },
  loadData: function() {
    // Complex data loading logic
  }
})

weui-wxss:

.weui-btn {
  position: relative;
  display: block;
  margin-left: auto;
  margin-right: auto;
  padding-left: 14px;
  padding-right: 14px;
}

The miniprogram-demo code showcases a more complete page structure with data loading, while weui-wxss focuses on styling UI components.

微信小程序开发资源汇总 :100:

Pros of awesome-wechat-weapp

  • Comprehensive collection of resources, libraries, and tools for WeChat Mini Program development
  • Regularly updated with community contributions, providing access to the latest resources
  • Organized into categories, making it easier to find specific types of resources

Cons of awesome-wechat-weapp

  • Lacks actual code examples or a demo application
  • May require additional research to determine the quality and relevance of listed resources
  • Not an official WeChat Mini Program resource

Code Comparison

miniprogram-demo:

Page({
  data: {
    text: 'This is page data.'
  },
  onLoad: function(options) {
    // Page load
  },
  onReady: function() {
    // Page ready
  }
})

awesome-wechat-weapp:

## 工具
- [WePY ★18k+](https://github.com/Tencent/wepy) - 微信小程序组件化开发框架
- [mpvue ★17k+](https://github.com/Meituan-Dianping/mpvue) - 基于 Vue.js 的小程序开发框架,从底层支持 Vue.js 语法和构建工具体系
- [Taro ★19k+](https://github.com/NervJS/taro) - 使用 React 的方式开发小程序的框架,同时支持生成多端应用

Note: awesome-wechat-weapp doesn't contain actual code examples, so the comparison shows a sample of its content structure instead.

微信小程序商城,微信小程序微店

Pros of wechat-app-mall

  • More comprehensive e-commerce functionality, including product listings, shopping cart, and order management
  • Includes a backend API integration for a complete shopping experience
  • Offers more real-world application features suitable for building a functional online store

Cons of wechat-app-mall

  • Less focus on demonstrating individual WeChat Mini Program components
  • May be more complex for beginners to understand and modify
  • Potentially less up-to-date with the latest WeChat Mini Program API changes

Code Comparison

miniprogram-demo (Component Demo):

Page({
  onShareAppMessage() {
    return {
      title: 'component-demo',
      path: 'page/component/index'
    }
  },
})

wechat-app-mall (E-commerce Functionality):

Page({
  data: {
    goodsList: [],
    categories: []
  },
  onLoad: function() {
    this.getCategories()
    this.getGoodsList()
  }
})

The code snippets highlight the difference in focus between the two repositories. miniprogram-demo emphasizes sharing and navigation within the demo app, while wechat-app-mall focuses on e-commerce functionality like loading product categories and listings.

36,420

开放式跨端跨框架解决方案,支持使用 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, and more
  • Familiar React-like syntax: Allows developers to use React/Vue concepts for easier adoption
  • Rich ecosystem: Offers a variety of UI components and plugins

Cons of Taro

  • Learning curve: Requires understanding of Taro-specific concepts and APIs
  • Potential performance overhead: May have slightly lower performance compared to native development
  • Limited access to platform-specific features: Some WeChat Mini Program features may not be fully supported

Code Comparison

miniprogram-demo (WeChat Mini Program native):

Page({
  data: {
    message: 'Hello, WeChat Mini Program!'
  },
  onLoad() {
    // Page initialization logic
  }
})

Taro:

import { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'

export default class Index extends Component {
  state = {
    message: 'Hello, Taro!'
  }
  render() {
    return (
      <View>
        <Text>{this.state.message}</Text>
      </View>
    )
  }
}

The code comparison shows that Taro uses a React-like component structure, while the native WeChat Mini Program uses a more traditional page-based approach. Taro's syntax may be more familiar to React developers, but it requires additional compilation steps to generate the final Mini Program code.

轻量、可靠的小程序 UI 组件库

Pros of vant-weapp

  • More comprehensive UI component library with a wider range of pre-built elements
  • Better documentation and examples for each component
  • Active community support and regular updates

Cons of vant-weapp

  • Less focus on WeChat Mini Program-specific features
  • May require more customization to match WeChat's native look and feel
  • Larger bundle size due to the extensive component library

Code Comparison

vant-weapp:

<van-button type="primary" bind:click="onButtonClick">Button</van-button>
<van-cell-group>
  <van-field label="Username" placeholder="Please enter username" />
  <van-field label="Password" type="password" placeholder="Please enter password" />
</van-cell-group>

miniprogram-demo:

<button type="primary" bindtap="onButtonTap">Button</button>
<view class="input-group">
  <input placeholder="Please enter username" />
  <input password placeholder="Please enter password" />
</view>

The vant-weapp code uses custom components with more built-in functionality, while miniprogram-demo relies on native WeChat Mini Program components. vant-weapp offers a more structured approach with pre-styled elements, whereas miniprogram-demo provides a basic foundation for custom styling and functionality.

腾讯云开发云原生一体化部署工具 🚀 CloudBase Framework:一键部署,不限框架语言,云端一体化开发,基于Serverless 架构。A front-end and back-end integrated deployment tool. One-click deploy to serverless architecture. https://docs.cloudbase.net/framework/index

Pros of cloudbase-framework

  • Provides a comprehensive cloud development framework for multiple platforms
  • Offers serverless architecture and cloud function support
  • Includes built-in CI/CD capabilities for easier deployment

Cons of cloudbase-framework

  • Steeper learning curve due to its more complex architecture
  • May be overkill for simple miniprogram projects
  • Requires Tencent Cloud account and potential associated costs

Code Comparison

miniprogram-demo:

Page({
  data: {
    message: 'Hello, Mini Program!'
  },
  onLoad: function() {
    // Page initialization logic
  }
})

cloudbase-framework:

const cloud = require('wx-server-sdk')
cloud.init()

exports.main = async (event, context) => {
  // Cloud function logic
  return { message: 'Hello from CloudBase!' }
}

The miniprogram-demo focuses on client-side code for WeChat Mini Programs, while cloudbase-framework emphasizes server-side logic and cloud functions. The cloudbase-framework example demonstrates how to create a cloud function, which can be called from a Mini Program or other platforms supported by the framework.

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

微信小程序示例

微信小程序示例源码,欢迎扫描以下小程序码体验。

提示:请使用微信开发者工具或微信客户端 6.7.2 及以上版本运行。

使用

npm run init

完成上述步骤后,使用微信开发者工具,点击【工具-构建npm】

使用微信开发者工具打开该示例代码,云开发环境搭建请参考云开发示例说明。

贡献

如果你有 bug 反馈或其他任何建议,欢迎提 issue 给我们。

如果你愿意一起来完善小程序示例,欢迎通过 PR 的方式贡献代码。为了保证代码风格的统一,在编写代码之前,请在项目根目录miniprogram下运行以下命令安装依赖:

npm install

同时,确保你的代码可以通过 Lint 检查:

npm run lint

截图