有哪些react多端统一框架?


当前第2页 返回上一页

在 Taro 中,你不用像小程序一样区分什么是 App 组件,什么是 Page 组件,什么是 Component 组件,Taro 全都是 Component 组件,并且和 React 的生命周期完全一致。可以说,一旦你掌握了 React,那就几乎掌握了 Taro。同样使用声明式的 JSX 语法。相比起字符串的模板语法,JSX 在处理精细复杂需求的时候会更得心应手。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

// 一个典型的 Taro 组件

import Taro, { Component } from '@tarojs/taro'

import { View, Button } from '@tarojs/components'

export default class Homeextends Component{

  constructor (props) {

    super(props)

    this.state = {

      title: '首页',

      list: [1, 2, 3]

    }

  }

  componentWillMount () {}

  componentDidMount () {}

  componentWillUpdate (nextProps, nextState) {}

  componentDidUpdate (prevProps, prevState) {}

  shouldComponentUpdate (nextProps, nextState) {

    return true

  }

  add = (e) => {

    // dosth

  }

  render () {

    const { list, title } = this.state

    return (

      <ViewclassName='index'>

        <ViewclassName='title'>{title}</View>

        <ViewclassName='content'>

          {list.map(item => {

            return (

              <ViewclassName='item'>{item}</View>

            )

          })}

          <ButtonclassName='add'onClick={this.add}>添加</Button>

        </View>

      </View>

    )

  }

}

更多编程相关知识,请访问:编程入门!!

以上就是有哪些react多端统一框架?的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

React封装自定义组件的正确步骤

React中文什么意思

React初级基础面试题(分享)

怎么修改React的antd默认样式

React中什么必须大写

一些关于React的常见面试题(分享)

React native是什么

怎么下载React

React中的portal是做什么的

React中图片怎么引用

更多相关阅读请进入《React》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...