Convert Figma logo to code with AI

Tencent logoweui.js

A lightweight javascript library for WeUI.

3,182
924
3,182
93

Top Related Projects

27,330

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

15,248

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

23,977

A lightweight, customizable Vue UI library for mobile web apps.

Essential UI blocks for building mobile web apps.

9,131

:large_orange_diamond: A fantastic mobile ui lib implement by Vue

16,528

Mobile UI elements for Vue.js

Quick Overview

WeUI.js is a JavaScript library that complements the WeUI CSS framework, providing interactive components and utilities for building WeChat-style web interfaces. It offers a set of easy-to-use methods for creating dialogs, toasts, loading indicators, and other UI elements commonly found in WeChat applications.

Pros

  • Seamless integration with WeUI CSS framework
  • Lightweight and easy to use
  • Provides a consistent WeChat-like user experience
  • Well-documented with examples and API references

Cons

  • Limited to WeChat-style interfaces, may not be suitable for other design systems
  • Dependency on WeUI CSS for full functionality
  • Less flexible compared to more comprehensive UI libraries
  • May require additional customization for complex applications

Code Examples

  1. Showing a toast message:
weui.toast('Operation Successful', 3000);
  1. Displaying a loading indicator:
const loading = weui.loading('Loading...');
setTimeout(() => {
    loading.hide();
}, 3000);
  1. Creating a dialog:
weui.confirm('Are you sure you want to delete this item?', {
    title: 'Confirm Deletion',
    buttons: [{
        label: 'Cancel',
        type: 'default',
        onClick: () => console.log('Cancelled')
    }, {
        label: 'Delete',
        type: 'warn',
        onClick: () => console.log('Deleted')
    }]
});

Getting Started

  1. Include WeUI CSS and WeUI.js in your HTML file:
<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/2.4.4/weui.min.css">
<script src="https://res.wx.qq.com/open/libs/weuijs/1.2.1/weui.min.js"></script>
  1. Start using WeUI.js methods in your JavaScript code:
document.querySelector('#showToast').addEventListener('click', () => {
    weui.toast('Hello, WeUI!');
});
  1. Refer to the official documentation for more advanced usage and available methods.

Competitor Comparisons

27,330

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

Pros of weui

  • Provides a comprehensive set of UI components for WeChat web development
  • Offers a native WeChat look and feel, ensuring consistency with the platform
  • Includes both CSS and HTML templates for easy implementation

Cons of weui

  • Requires more manual JavaScript implementation for interactive components
  • Less flexibility for customizing component behavior without additional code

Code comparison

weui (HTML and CSS):

<a href="javascript:;" class="weui-btn weui-btn_primary">Primary Button</a>

weui.js (JavaScript):

weui.alert('This is an alert message');

Key differences

weui is primarily a CSS framework with HTML templates, while weui.js is a JavaScript library that extends weui's functionality. weui.js provides pre-built JavaScript components and interactions, making it easier to implement complex UI elements and behaviors without writing custom JavaScript code.

weui is more suitable for developers who prefer greater control over their JavaScript implementation and want to build custom interactions. On the other hand, weui.js is ideal for rapid development and prototyping, as it offers ready-to-use JavaScript components that integrate seamlessly with weui's CSS styles.

Both repositories complement each other, with weui providing the visual foundation and weui.js offering enhanced interactivity and functionality. Developers can choose to use them together or separately, depending on their project requirements and development preferences.

15,248

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

Pros of weui-wxss

  • Specifically designed for WeChat Mini Programs, offering a more tailored UI experience
  • Provides a comprehensive set of CSS styles for WeChat-specific components
  • Lighter weight, focusing solely on styles without JavaScript functionality

Cons of weui-wxss

  • Limited to WeChat Mini Programs, less versatile for other web applications
  • Requires additional JavaScript implementation for interactive components
  • May require more custom code for complex UI interactions

Code Comparison

weui-wxss:

.weui-btn {
  position: relative;
  display: block;
  margin-left: auto;
  margin-right: auto;
  padding-left: 14px;
  padding-right: 14px;
  box-sizing: border-box;
  font-size: 18px;
  text-align: center;
  text-decoration: none;
  color: #FFFFFF;
  line-height: 2.55555556;
  border-radius: 5px;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  overflow: hidden;
}

weui.js:

weui.alert('Alert 标题', function() {
  console.log('ok')
});

weui.confirm('Confirm 标题', function() {
  console.log('ok')
}, function() {
  console.log('cancel')
});

The code snippets demonstrate the focus on CSS styling in weui-wxss, while weui.js provides JavaScript functions for interactive UI elements.

23,977

A lightweight, customizable Vue UI library for mobile web apps.

Pros of Vant

  • More comprehensive component library with 70+ UI components
  • Better support for Vue 3 and TypeScript
  • Active development with frequent updates and releases

Cons of Vant

  • Larger bundle size due to more components
  • Steeper learning curve for developers new to Vue

Code Comparison

Vant:

import { createApp } from 'vue';
import { Button } from 'vant';

const app = createApp();
app.use(Button);

Weui.js:

import weui from 'weui.js';

weui.alert('Hello World');

Key Differences

  • Vant is a Vue-based UI framework, while Weui.js is a vanilla JavaScript library
  • Vant offers a more modular approach, allowing developers to import only needed components
  • Weui.js provides a simpler API for basic UI interactions, making it easier for beginners

Use Cases

  • Vant: Ideal for large-scale Vue applications requiring a comprehensive UI toolkit
  • Weui.js: Better suited for smaller projects or those needing quick implementation of WeChat-style UI elements

Community and Ecosystem

  • Vant has a larger community and more third-party extensions
  • Weui.js benefits from Tencent's backing and integration with WeChat ecosystem

Essential UI blocks for building mobile web apps.

Pros of ant-design-mobile

  • More comprehensive UI component library with a wider range of components
  • Better documentation and examples, making it easier for developers to use
  • Active development and frequent updates, ensuring compatibility with latest React versions

Cons of ant-design-mobile

  • Larger bundle size, which may impact performance for smaller projects
  • Steeper learning curve due to its extensive API and customization options
  • Less native-like appearance on iOS devices compared to weui.js

Code Comparison

ant-design-mobile:

import { Button } from 'antd-mobile'

const App = () => (
  <Button color='primary' onClick={() => console.log('Clicked')}>
    Click me
  </Button>
)

weui.js:

import weui from 'weui.js'

weui.button('Click me', function() {
  console.log('Clicked')
})

The code comparison shows that ant-design-mobile uses a more React-centric approach with components, while weui.js relies on a more imperative style. ant-design-mobile's approach is generally more flexible and easier to integrate into React applications, but weui.js may be simpler for basic use cases or for developers more familiar with traditional JavaScript patterns.

9,131

:large_orange_diamond: A fantastic mobile ui lib implement by Vue

Pros of cube-ui

  • More comprehensive UI component library with a wider range of components
  • Built-in support for Vue.js, making it easier to integrate with Vue applications
  • Offers a powerful CLI tool for customization and theme generation

Cons of cube-ui

  • Larger file size and potentially higher learning curve due to more components
  • Less focused on WeChat-specific design patterns compared to weui.js
  • May require more configuration and setup for optimal use

Code Comparison

weui.js:

weui.alert('Alert message', function() {
    console.log('OK');
});

cube-ui:

this.$createDialog({
    type: 'alert',
    title: 'Alert',
    content: 'Alert message',
    onConfirm: () => {
        console.log('OK')
    }
}).show()

Both libraries provide ways to create alert dialogs, but cube-ui's implementation is more Vue-centric and offers more customization options out of the box. weui.js focuses on simplicity and follows WeChat's design patterns more closely, while cube-ui provides a more feature-rich and flexible approach for general Vue.js applications.

16,528

Mobile UI elements for Vue.js

Pros of mint-ui

  • More comprehensive UI component library with a wider range of components
  • Better suited for building complex mobile applications
  • Offers a more modern and sleek design aesthetic

Cons of mint-ui

  • Larger file size and potentially heavier performance impact
  • Less focused on WeChat-specific design patterns and conventions
  • May require more configuration and customization for WeChat-centric projects

Code Comparison

mint-ui (Vue.js component):

<template>
  <mt-button type="primary" size="large">Primary Button</mt-button>
</template>

<script>
import { Button } from 'mint-ui'
export default {
  components: { 'mt-button': Button }
}
</script>

weui.js (JavaScript usage):

weui.alert('This is an alert message', function() {
  console.log('Alert callback')
})

mint-ui is a more comprehensive Vue.js-based UI framework for mobile applications, offering a wider range of components and a modern design. It's better suited for complex mobile apps but may be overkill for simpler WeChat-focused projects. weui.js, on the other hand, is specifically tailored for WeChat-style interfaces and is lighter weight, making it more appropriate for WeChat Mini Programs or web apps that need to closely match WeChat's design language. The code examples demonstrate the different approaches: mint-ui uses Vue components, while weui.js provides a more traditional JavaScript API.

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

weui.js

npm version

概述

WeUI 的轻量级 js 封装。

注意:由于微信小程序不支持dom操作,所以weui.js并不适用于小程序。不过WeUI也为小程序开发了另外的版本,详情请看:https://github.com/Tencent/weui-wxss/

手机预览

https://weui.io

https://weui.io/weui.js/

开发

安装

git clone https://github.com/Tencent/weui.js.git
cd weui.js
npm install
npm start

编译

npm run build

使用

global

<link rel="stylesheet" href="https://res.wx.qq.com/t/wx_fed/weui-source/res/2.5.16/weui.min.css">
<script type="text/javascript" src="https://res.wx.qq.com/t/wx_fed/weui.js/res/1.2.21/weui.min.js"></script>
<script type="text/javascript">
    weui.alert('alert');
</script>

import as module

import 'weui';
import weui from 'weui.js';

weui.alert('alert');

文档

Documents

贡献

如果你有好的意见或建议,欢迎给我们提issue或pull request。

License

The MIT License(http://opensource.org/licenses/MIT)

请自由地享受和参与开源

NPM DownloadsLast 30 Days