候选框架

react-native / flutter / weex / uni-app

目前技术方面,从成本和人员情况上看,不考虑原生开发,以上都是跨平台的解决方案,即写一份代码可以同时在ios、android上运行

各框架优劣

uni-app:

一套代码编译到7个平台,难以置信吗?依次扫描7个二维码,亲自体验最全面的跨平台效果!

github:

总结: 后台不硬,社区不是很活跃,也没有大公司在用,尚不成熟。并且多端兼容必然带来更多的差异化处理。

weex:

A framework for building Mobile cross-platform UI https://weex.apache.org/

github上已经归档:

写法:

  1. <template>
  2. <div><text>Toast</text></div>
  3. </template>
  4. <script>
  5. const modal = weex.requireModule('modal')
  6. modal.toast({
  7. message: 'I am a toast.',
  8. duration: 3
  9. })
  10. </script>

总结:比较贴近js + html写法,类似于vue,目前主要阿里在用,但是自建社区不够活跃,插件也不够丰富

react-native / flutter

flutter语法:
  1. Future<void> getBatteryLevel() async {
  2. var batteryLevel = 'unknown';
  3. try {
  4. int result = await methodChannel.invokeMethod('getBatteryLevel');
  5. batteryLevel = 'Battery level: $result%';
  6. } on PlatformException {
  7. batteryLevel = 'Failed to get battery level.';
  8. }
  9. setState(() {
  10. _batteryLevel = batteryLevel;
  11. });
  12. }
react-native语法:
  1. import React, { Component } from 'react'
  2. import {
  3. ActivityIndicator,
  4. AppRegistry,
  5. StyleSheet,
  6. Text,
  7. View,
  8. } from 'react-native'
  9. export default class App extends Component {
  10. render() {
  11. return (
  12. <View style={[styles.container, styles.horizontal]}>
  13. <ActivityIndicator size="large" color="#0000ff" />
  14. <ActivityIndicator size="small" color="#00ff00" />
  15. <ActivityIndicator size="large" color="#0000ff" />
  16. <ActivityIndicator size="small" color="#00ff00" />
  17. </View>
  18. )
  19. }
  20. }
  21. const styles = StyleSheet.create({
  22. container: {
  23. flex: 1,
  24. justifyContent: 'center'
  25. },
  26. horizontal: {
  27. flexDirection: 'row',
  28. justifyContent: 'space-around',
  29. padding: 10
  30. }
  31. })
  32. AppRegistry.registerComponent('App', () => App)
文档更新时间: 2021-08-03 09:57