UI
但是写过前端程序的朋友,肯定不希望每次开发都学习一套新的语法,一来学习成本比较高,二来已有的知识无法复用,也很憋屈。所以下面来介绍一款也许能够缩短微信小程序开发成本的工具:
Taro 是一个开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发 微信 / 京东 / 百度 / 支付宝 / 字节跳动 / QQ / 飞书 小程序 / H5 / RN 等应用。
React开发语法
import React, { Component } from 'react'import { View, Text } from '@tarojs/components'export default class Index extends Component { state = { msg: 'Hello World!' } componentWillMount () { } componentDidShow () { } componentDidHide () { } render () { return ( <View className='index'> <Text>{this.state.msg}</Text> </View> ) }}
Vue开发语法
<template> <view class="index"> <text>{{msg}}</text> </view></template><script>export default { data () { return { msg: 'Hello World!' } }, created () {}, onShow () {}, onHide () {}}</script>
按照taro的使用文档即可编译出微信小程序:
https://docs.taro.zone/docs/GETTING-STARTED