Top Related Projects
A UI library by WeChat official design team, includes the most useful widgets/modules in mobile web applications.
A UI library by WeChat official design team, includes the most useful widgets/modules.
A lightweight, customizable Vue UI library for mobile web apps.
Essential UI blocks for building mobile web apps.
:large_orange_diamond: A fantastic mobile ui lib implement by Vue
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
- Showing a toast message:
weui.toast('Operation Successful', 3000);
- Displaying a loading indicator:
const loading = weui.loading('Loading...');
setTimeout(() => {
loading.hide();
}, 3000);
- 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
- 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>
- Start using WeUI.js methods in your JavaScript code:
document.querySelector('#showToast').addEventListener('click', () => {
weui.toast('Hello, WeUI!');
});
- Refer to the official documentation for more advanced usage and available methods.
Competitor Comparisons
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.
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.
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.
: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.
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
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
weui.js
æ¦è¿°
WeUI çè½»é级 js å°è£ ã
注æï¼ç±äºå¾®ä¿¡å°ç¨åºä¸æ¯ædomæä½ï¼æä»¥weui.jså¹¶ä¸éç¨äºå°ç¨åºãä¸è¿WeUIä¹ä¸ºå°ç¨åºå¼åäºå¦å¤ççæ¬ï¼è¯¦æ 请çï¼https://github.com/Tencent/weui-wxss/
ææºé¢è§
å¼å
å®è£
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');
ææ¡£
è´¡ç®
å¦æä½ æå¥½çæè§æå»ºè®®ï¼æ¬¢è¿ç»æä»¬æissueæpull requestã
License
The MIT License(http://opensource.org/licenses/MIT)
请èªç±å°äº«åååä¸å¼æº
Top Related Projects
A UI library by WeChat official design team, includes the most useful widgets/modules in mobile web applications.
A UI library by WeChat official design team, includes the most useful widgets/modules.
A lightweight, customizable Vue UI library for mobile web apps.
Essential UI blocks for building mobile web apps.
:large_orange_diamond: A fantastic mobile ui lib implement by Vue
Mobile UI elements for Vue.js
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