taro
开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
Top Related Projects
A framework for building native applications using React
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
Flutter makes it easy and fast to build beautiful apps for mobile and beyond
Remote Administration Tool for Windows
Full featured HTML framework for building iOS & Android apps
Quick Overview
Taro is an open-source framework for building cross-platform applications using React. It allows developers to write once and deploy to multiple platforms, including WeChat Mini Programs, H5, React Native, and more. Taro aims to provide a unified development experience across different platforms.
Pros
- Cross-platform development: Write code once and deploy to multiple platforms
- Large ecosystem: Extensive plugin system and component library
- React-based: Familiar syntax and concepts for React developers
- Active community: Regular updates and strong support
Cons
- Learning curve: Requires understanding of React and platform-specific concepts
- Performance overhead: Cross-platform nature may lead to some performance trade-offs
- Limited native functionality: Some platform-specific features may not be fully supported
Code Examples
- Creating a simple component:
import { Component } from 'react'
import { View, Text } from '@tarojs/components'
export default class HelloWorld extends Component {
render () {
return (
<View className='hello-world'>
<Text>Hello, World!</Text>
</View>
)
}
}
- Using Taro hooks:
import { useState, useEffect } from 'react'
import { View, Text } from '@tarojs/components'
function Counter() {
const [count, setCount] = useState(0)
useEffect(() => {
console.log('Count changed:', count)
}, [count])
return (
<View onClick={() => setCount(count + 1)}>
<Text>You clicked {count} times</Text>
</View>
)
}
- Making an API request:
import Taro from '@tarojs/taro'
Taro.request({
url: 'https://api.example.com/data',
method: 'GET',
success: (res) => {
console.log('Response:', res.data)
},
fail: (err) => {
console.error('Error:', err)
}
})
Getting Started
- Install Taro CLI:
npm install -g @tarojs/cli
- Create a new Taro project:
taro init myApp
cd myApp
- Start development server:
npm run dev:h5
- Build for production:
npm run build:h5
Replace h5
with the target platform (e.g., weapp
for WeChat Mini Program, rn
for React Native) as needed.
Competitor Comparisons
A framework for building native applications using React
Pros of React Native
- Larger community and ecosystem, with more third-party libraries and resources
- Better performance for complex, animation-heavy applications
- More mature and battle-tested in production environments
Cons of React Native
- Steeper learning curve, especially for developers new to mobile development
- More complex setup and configuration process
- Larger app size due to bundled JavaScript runtime
Code Comparison
React Native:
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
const App = () => (
<View style={styles.container}>
<Text>Hello, React Native!</Text>
</View>
);
Taro:
import { Component } from 'react'
import { View, Text } from '@tarojs/components'
class App extends Component {
render () {
return (
<View className='container'>
<Text>Hello, Taro!</Text>
</View>
)
}
}
Key Differences
- Taro focuses on cross-platform development for multiple mini-program platforms, while React Native primarily targets iOS and Android
- Taro uses a unified API that works across different platforms, whereas React Native requires platform-specific code in some cases
- Taro has better integration with popular Chinese platforms like WeChat and Alipay
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
Pros of Ionic Framework
- Broader platform support, including iOS, Android, and web
- Larger community and ecosystem with more plugins and resources
- More mature and established framework with longer history
Cons of Ionic Framework
- Steeper learning curve, especially for developers new to Angular
- Potentially larger app size due to inclusion of Cordova and other dependencies
- Performance may be slower compared to native apps or Taro-built apps
Code Comparison
Ionic Framework (Angular):
@Component({
selector: 'app-home',
template: `
<ion-content>
<ion-button (click)="showAlert()">Click Me</ion-button>
</ion-content>
`
})
export class HomePage {
constructor(private alertController: AlertController) {}
async showAlert() {
const alert = await this.alertController.create({
header: 'Alert',
message: 'This is an alert message.',
buttons: ['OK']
});
await alert.present();
}
}
Taro:
import Taro from '@tarojs/taro'
import { View, Button } from '@tarojs/components'
export default class Index extends Component {
showAlert = () => {
Taro.showModal({
title: 'Alert',
content: 'This is an alert message.',
showCancel: false
})
}
render () {
return (
<View>
<Button onClick={this.showAlert}>Click Me</Button>
</View>
)
}
}
Flutter makes it easy and fast to build beautiful apps for mobile and beyond
Pros of Flutter
- Cross-platform development for mobile, web, and desktop from a single codebase
- Rich set of pre-built widgets and tools for creating custom UI designs
- Hot reload feature for faster development and testing
Cons of Flutter
- Larger app size compared to native applications
- Steeper learning curve for developers new to Dart programming language
- Limited access to some platform-specific features
Code Comparison
Flutter:
import 'package:flutter/material.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Flutter App')),
body: Center(child: Text('Hello, World!')),
),
);
}
}
Taro:
import { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
export default class Index extends Component {
render () {
return (
<View className='index'>
<Text>Hello, World!</Text>
</View>
)
}
}
Summary
Flutter offers a comprehensive cross-platform solution with a rich set of tools and widgets, while Taro focuses on building mini-programs and H5 applications using React-like syntax. Flutter's use of Dart may present a learning curve, but it provides excellent performance and a consistent UI across platforms. Taro leverages familiar web technologies, making it easier for web developers to adopt, but may have limitations in terms of native functionality compared to Flutter.
Remote Administration Tool for Windows
Pros of Quasar
- More comprehensive UI component library with Material Design support
- Better documentation and community support
- Supports both web and mobile development with a single codebase
Cons of Quasar
- Steeper learning curve due to its extensive feature set
- Larger bundle size compared to Taro
- Less focused on WeChat mini-program development
Code Comparison
Taro (React-like syntax):
import { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
export default class Index extends Component {
render () {
return (
<View className='index'>
<Text>Hello, World!</Text>
</View>
)
}
}
Quasar (Vue-based syntax):
<template>
<q-page class="flex flex-center">
<q-btn color="primary" label="Hello, World!" />
</q-page>
</template>
<script>
export default {
name: 'PageIndex'
}
</script>
Both frameworks offer cross-platform development capabilities, but Taro is more focused on WeChat mini-programs and React-like development, while Quasar provides a more comprehensive solution for Vue-based web and mobile app development with a rich set of UI components.
Full featured HTML framework for building iOS & Android apps
Pros of Framework7
- More mature and established project with a larger community and ecosystem
- Offers a complete UI framework with pre-built components for rapid development
- Supports both web and hybrid mobile app development
Cons of Framework7
- Steeper learning curve due to its comprehensive nature
- Less flexible for custom designs and may require more effort to override default styles
- Limited to iOS and Android-like UI, which may not be suitable for all projects
Code Comparison
Framework7:
const app = new Framework7({
root: '#app',
name: 'My App',
theme: 'auto',
routes: [
// Define routes here
]
});
Taro:
import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
class Index extends Component {
render () {
return (
<View>
<Text>Hello, World!</Text>
</View>
)
}
}
Framework7 uses a more configuration-based approach, while Taro follows a React-like component structure. Framework7's code is focused on initializing the app with various options, whereas Taro's code demonstrates a simple component declaration.
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
Taro
å¼æ¾å¼è·¨ç«¯è·¨æ¡æ¶è§£å³æ¹æ¡ï¼è½»æ¾æ建å¯ä»¥è¿è¡å¨ å°ç¨åº/Web/APP ä¸çåºç¨
ð½ Taro['tÉ:roÊ]ï¼æ³°ç½Â·å¥¥ç¹æ¼ï¼å®å®è¦å¤éæ»æå®ï¼å®åæ强ç奥ç¹æ¼ã
ç®å½
- ç®ä»
- å¦ä¹ èµæº
- 社åºå ±äº«
- 项ç®ç¶æ
- 使ç¨æ¡ä¾
- å å ¥å ±å»º
- é®é¢åé¦ä¸å»ºè®®
- ç¹å«é¸£è°¢
- è´¡ç®è 们
- å¼å计å
- æ´æ°æ¥å¿
- å¼å交æµ
ç®ä»
å¼æ¾å¼è·¨ç«¯è·¨æ¡æ¶è§£å³æ¹æ¡ï¼æ¯æä½¿ç¨ React/Vue/Nerv çæ¡æ¶æ¥å¼å微信/京ä¸/ç¾åº¦/æ¯ä»å®/åèè·³å¨/ QQ å°ç¨åº/H5/React Native çåºç¨ãç°å¦ä»å¸é¢ä¸ç«¯çå½¢æå¤ç§å¤æ ·ï¼WebãReact Nativeã微信å°ç¨åºçåç§ç«¯å¤§è¡å ¶éï¼å½ä¸å¡è¦æ±åæ¶å¨ä¸åç端é½è¦æ±ææ表ç°çæ¶åï¼é对ä¸åç端å»ç¼åå¤å¥ä»£ç çææ¬æ¾ç¶é常é«ï¼è¿æ¶ååªç¼åä¸å¥ä»£ç å°±è½å¤éé å°å¤ç«¯çè½åå°±æ¾å¾æ为éè¦
çæ¬è¿ç§»
Taro 1/2 è¿ç§»è³ Taro 3ï¼è¯·é 读ãTaro çæ¬å级æå¨æåã
å¦ä¹ èµæº
社åºå ±äº«
Taro ç©æå¸åºââ让æ¯ä¸ä¸ªè½®å产çä»·å¼
UI åº
å称 | å°å | ä»ç» | æ¯æçæ¡æ¶ | æ¯æç Taro çæ¬ |
---|---|---|---|---|
taro-ui | https://taro-ui.jd.com/#/ | ä¸å¥åºäº Taro æ¡æ¶å¼åçå¤ç«¯ UI ç»ä»¶åº | React | Taro 1/2/3 |
NutUI | https://nutui.jd.com/#/ | 京ä¸é£æ ¼çè½»é级移å¨ç«¯ Vue ç»ä»¶åº | Vue3 | Taro 3 |
taroify | https://taroify.gitee.io/taroify.com/introduce/ | è½»éãå¯é çå°ç¨åºç«¯ Taro ç»ä»¶åºï¼Vant ç Taro çæ¬ï¼ | React | Taro 3 |
@antmjs/vantui | https://antmjs.github.io/vantui/#/home | åºäºæèµ VantWeapp å¼åçåæ¶æ¯æ Taro å React ç UI åº | React | Taro 3 |
Tard | https://tard-ui.selling.cn/ | ä¸å¥åºäº Taro æ¡æ¶å¼åçå¤ç«¯ React UI ç»ä»¶åº | React | Taro 3 |
项ç®ç¶æ
使ç¨æ¡ä¾
Taro å·²ç»æå ¥äºæ们çç产ç¯å¢ä¸ä½¿ç¨ï¼ä¸çä¹å¨å¹¿æ³å°ä½¿ç¨ Taro å¼åå¤ç«¯åºç¨ã
å å ¥å ±å»º
å å ¥ Taro 社åºå ±å»ºå¡è®®
为 Taro è´¡ç®ä»£ç
Taro é常欢è¿ç¤¾åºå¼åè 为 Taro è´¡ç®ä»£ç ï¼å¨è´¡ç®ä¹å请å é 读贡ç®æåã
å¦æä½ æ³ä¸º Taro å®ç°ä¸ä¸ªéè¦åè½ï¼éè¦å æ°å RFC ææ¡£ï¼æç § Taro çRFC æºå¶è¿è¡æä½ï¼å¨ç»è¿ç¤¾åºè®¨è®ºå®ååæå¯ä»¥è¿è¡ä»£ç çæ交ã
é®é¢åé¦ä¸å»ºè®®
强çæ¨èé 读 ãæé®çæºæ §ãããå¦ä½åå¼æºç¤¾åºæé®é¢ã å ãå¦ä½ææå°æ¥å Bugãããå¦ä½åå¼æºé¡¹ç®æ交æ æ³è§£ççé®é¢ãï¼æ´å¥½çé®é¢æ´å®¹æè·å¾å¸®å©ã
ç¹å«é¸£è°¢
nanjingboy | jsNewbee | Qiyu8 | Garfield Lee |
è´¡ç®è 们
å¼å计å
æ´æ°æ¥å¿
æ¬é¡¹ç®éµä» Angular Style Commit Message Conventionsï¼æ´æ°æ¥å¿è¯·æ¥é Releaseã
å¼å交æµ
License
MIT License
Copyright (c) O2Team
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Top Related Projects
A framework for building native applications using React
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
Flutter makes it easy and fast to build beautiful apps for mobile and beyond
Remote Administration Tool for Windows
Full featured HTML framework for building iOS & Android apps
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