Convert Figma logo to code with AI

youzan logovant-weapp

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

17,728
3,475
17,728
74

Top Related Projects

15,076

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

:dog: 一套组件化、可复用、易扩展的微信小程序 UI 组件库

一套高质量的微信小程序 UI 组件库

鲜亮的高饱和色彩,专注视觉的小程序组件库

微信小程序 商城demo

Quick Overview

Vant Weapp is a popular and comprehensive UI component library for building WeChat mini-programs (WeChat apps). It provides a wide range of high-quality components and tools to help developers create efficient and visually appealing mini-programs.

Pros

  • Comprehensive Component Library: Vant Weapp offers a vast collection of UI components, including buttons, forms, navigation, feedback, and more, covering most common use cases in mini-program development.
  • Customizable and Themeable: The library allows for easy customization of styles and themes, enabling developers to align the UI with their brand's visual identity.
  • Actively Maintained and Supported: The project is actively maintained by the Youzan team, with regular updates, bug fixes, and community support.
  • Excellent Documentation and Examples: The project's documentation is well-organized and provides clear explanations, code examples, and guidelines for using the components.

Cons

  • Specific to WeChat Mini-Programs: Vant Weapp is designed specifically for WeChat mini-programs and may not be directly applicable to other mobile app platforms.
  • Learning Curve for Newcomers: The library's extensive feature set and customization options can present a learning curve for developers new to Vant Weapp.
  • Potential Performance Concerns: Depending on the complexity of the mini-program and the number of components used, there may be performance considerations to keep in mind.
  • Limited Cross-Platform Support: Vant Weapp is primarily focused on WeChat mini-programs and may not have the same level of support or integration for other platforms, such as Alipay or Taro.

Code Examples

Here are a few examples of how to use Vant Weapp components:

  1. Button Component:
<van-button type="primary" bindtap="onClick">Primary Button</van-button>

This code snippet demonstrates the usage of the van-button component, which renders a primary-colored button that triggers the onClick function when tapped.

  1. Form Field Component:
<van-field
  value="{{ fieldValue }}"
  label="Field Label"
  placeholder="Field Placeholder"
  bind:change="onFieldChange"
/>

This example shows the van-field component, which renders a form field with a label, placeholder, and binds the onFieldChange function to the change event.

  1. List Component:
<van-list
  loading="{{ loading }}"
  finished="{{ finished }}"
  finished-text="No more data"
  bind:load="onLoad"
>
  <van-cell
    wx:for="{{ items }}"
    wx:key="index"
    title="{{ item.title }}"
    label="{{ item.label }}"
  />
</van-list>

This code snippet demonstrates the usage of the van-list component, which renders a list of items using the van-cell component. The list supports loading more data when the user scrolls to the bottom, and displays a "No more data" message when the data is fully loaded.

Getting Started

To get started with Vant Weapp, follow these steps:

  1. Install the library using npm or yarn:
npm install @vant/weapp -S
  1. In your mini-program's app.json file, import the Vant Weapp styles:
"style": "v2",
"usingComponents": {
  "van-button": "@vant/weapp/button/index",
  "van-field": "@vant/weapp/field/index",
  "van-list": "@vant/weapp/list/index",
  "van-cell": "@vant/weapp/cell/index"
}
  1. In your mini-program's WXML file, use the Vant Weapp components:
<van-button type="primary" bindtap="onClick">Primary Button</van-button>
  1. Customize the components by passing in the appropriate props and binding event handlers:
<van-field
  value="{{ fieldValue }}"
  label="Field Label"
  placeholder="Field Placeholder"
  bind:change="onFieldChange

Competitor Comparisons

15,076

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

Pros of weui-wxss

  • Official UI library developed by Tencent, ensuring compatibility with WeChat Mini Program standards
  • Lightweight and minimalistic design, closely following WeChat's native look and feel
  • Extensive documentation and examples provided by Tencent

Cons of weui-wxss

  • Limited number of components compared to vant-weapp
  • Less frequent updates and slower adoption of new WeChat Mini Program features
  • Fewer customization options and theming capabilities

Code Comparison

weui-wxss:

<view class="weui-cells">
  <view class="weui-cell">
    <view class="weui-cell__bd">Cell Content</view>
    <view class="weui-cell__ft">Details</view>
  </view>
</view>

vant-weapp:

<van-cell-group>
  <van-cell title="Cell Content" value="Details" />
</van-cell-group>

The code comparison shows that vant-weapp offers a more concise and declarative approach to creating UI components, while weui-wxss relies on traditional class-based styling. vant-weapp's component-based structure allows for easier implementation and maintenance, whereas weui-wxss provides greater flexibility in customizing individual elements within a component.

:dog: 一套组件化、可复用、易扩展的微信小程序 UI 组件库

Pros of wux-weapp

  • More comprehensive component library with a wider range of UI elements
  • Highly customizable components with extensive configuration options
  • Better documentation and examples for each component

Cons of wux-weapp

  • Larger file size and potentially slower performance due to the extensive component library
  • Steeper learning curve for developers new to the framework
  • Less frequent updates and maintenance compared to vant-weapp

Code Comparison

wux-weapp:

<wux-button size="default" type="positive">Default</wux-button>
<wux-input label="Name" placeholder="Enter your name" />
<wux-calendar value="{{ value }}" bind:change="onChange" />

vant-weapp:

<van-button type="primary">Primary</van-button>
<van-field label="Name" placeholder="Enter your name" />
<van-calendar show="{{ show }}" bind:close="onClose" bind:confirm="onConfirm" />

Both frameworks offer similar components, but wux-weapp tends to provide more customization options and a wider variety of UI elements. vant-weapp, on the other hand, focuses on simplicity and ease of use, which can be beneficial for smaller projects or developers who prefer a more straightforward approach.

When choosing between the two, consider your project's requirements, team expertise, and the level of customization needed. wux-weapp might be better suited for complex applications with unique UI needs, while vant-weapp could be more appropriate for rapid development of simpler interfaces.

一套高质量的微信小程序 UI 组件库

Pros of iview-weapp

  • More comprehensive UI component library with a wider range of components
  • Follows the iView design system, providing a consistent and professional look
  • Better documentation and examples for each component

Cons of iview-weapp

  • Less frequent updates and maintenance compared to vant-weapp
  • Smaller community and fewer third-party extensions
  • May have a steeper learning curve for developers new to iView

Code Comparison

vant-weapp:

<van-button type="primary" bind:click="onClick">Button</van-button>
<van-cell-group>
  <van-field label="Username" model:value="{{ username }}" placeholder="Please enter username" />
</van-cell-group>

iview-weapp:

<i-button type="primary" bind:click="handleClick">Button</i-button>
<i-panel title="Input">
    <i-input value="{{ value1 }}" title="Username" autofocus placeholder="Please enter username" />
</i-panel>

Both libraries offer similar component structures, but with different naming conventions and slight variations in attribute names. iview-weapp tends to use more nested components (e.g., i-panel), while vant-weapp often uses flatter structures.

vant-weapp generally has a more minimalist approach, focusing on essential functionality, while iview-weapp provides more detailed and customizable components. The choice between the two depends on project requirements, design preferences, and developer familiarity with each library's ecosystem.

鲜亮的高饱和色彩,专注视觉的小程序组件库

Pros of ColorUI

  • More lightweight and focused on UI styling, making it easier to customize
  • Offers a wider range of pre-designed color schemes and gradients
  • Provides a more visually appealing default design out of the box

Cons of ColorUI

  • Less comprehensive component library compared to Vant Weapp
  • Limited documentation and community support
  • Fewer built-in interactive components and form elements

Code Comparison

ColorUI example:

<view class="cu-bar bg-gradual-blue">
  <view class="content">ColorUI Header</view>
</view>

Vant Weapp example:

<van-nav-bar
  title="Vant Weapp Header"
  left-text="Back"
  right-text="Button"
  left-arrow
/>

ColorUI focuses on providing CSS classes for styling, while Vant Weapp offers more structured components with built-in functionality. ColorUI's approach allows for quicker styling but may require more custom JavaScript for interactive elements. Vant Weapp provides a more comprehensive set of pre-built components, which can lead to faster development of complex interfaces but may be less flexible in terms of custom designs.

微信小程序 商城demo

Pros of wxapp-mall

  • Provides a complete e-commerce solution with features like product listing, shopping cart, and order management
  • Includes a backend management system for easier product and order administration
  • Offers a more comprehensive and ready-to-use mall application structure

Cons of wxapp-mall

  • Less frequently updated compared to vant-weapp, potentially lacking the latest WeChat Mini Program features
  • May require more customization effort to fit specific business needs
  • Smaller community and fewer contributors, which could result in slower bug fixes and feature additions

Code Comparison

vant-weapp (Component-based approach):

<van-button type="primary">Button</van-button>
<van-cell-group>
  <van-field label="Username" placeholder="Please enter username" />
</van-cell-group>

wxapp-mall (Traditional WeChat Mini Program approach):

<view class="btn-area">
  <button type="primary">Button</button>
</view>
<view class="section">
  <input placeholder="Please enter username" />
</view>

vant-weapp focuses on providing reusable UI components, while wxapp-mall offers a more traditional WeChat Mini Program structure with custom-built UI elements. vant-weapp's approach allows for easier maintenance and consistency across the application, whereas wxapp-mall provides a complete e-commerce solution out of the box.

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

logo

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

npm version downloads downloads

🔥 文档网站(国内)   🔥 文档网站(GitHub)   🚀 Vue 版


介绍

Vant 是一个轻量、可靠的移动端组件库,于 2017 年开源。

目前 Vant 官方提供了 Vue 2 版本、Vue 3 版本和微信小程序版本,并由社区团队维护 React 版本和支付宝小程序版本。

预览

扫描下方小程序二维码,体验组件库示例。注意:因微信审核机制限制,目前示例小程序不是最新版本,可以 clone 代码到本地开发工具预览

使用之前

使用 Vant Weapp 前,请确保你已经学习过微信官方的 小程序简易教程 和 自定义组件介绍。

安装

方式一. 通过 npm 安装 (推荐)

小程序已经支持使用 npm 安装第三方包,详见 npm 支持

# 通过 npm 安装
npm i @vant/weapp -S --production

# 通过 yarn 安装
yarn add @vant/weapp --production

# 安装 0.x 版本
npm i vant-weapp -S --production

方式二. 下载代码

直接通过 git 下载 Vant Weapp 源代码,并将 dist 目录拷贝到自己的项目中。

git clone https://github.com/youzan/vant-weapp.git

使用组件

以按钮组件为例,只需要在 json 文件中引入按钮对应的自定义组件即可

{
  "usingComponents": {
    "van-button": "/path/to/vant-weapp/dist/button/index"
  }
}

接着就可以在 wxml 中直接使用组件

<van-button type="primary">按钮</van-button>

在开发者工具中预览

# 安装项目依赖
npm install

# 执行组件编译
npm run dev

打开微信开发者工具,把vant-weapp/example目录添加进去就可以预览示例了。

PS:关于 van-area Area 省市区选择组件,地区数据初始化可以直接在云开发环境中导入vant-weapp/example/database_area.JSON 文件使用。

基础库版本

Vant Weapp 最低支持到小程序基础库 2.6.5 版本。

链接

核心团队

以下是 Vant 和 Vant Weapp 的核心贡献者们:

chenjiahancookfrontw91pangxie1991rex-zsdnemo-shen
chenjiahancookfrontwangnaiyipangxierex-zsdnemo-shen
LindysenJakeLaoyulandluckwjw-gavininottnzhousg
LindysenJakeLaoyulandluckwjw-gavininottnzhousg

贡献者们

感谢以下小伙伴们为 Vant Weapp 发展做出的贡献:

contributors

开源协议

本项目基于 MIT协议,请自由地享受和参与开源。

NPM DownloadsLast 30 Days