taro循环一个渐变的View

Posted on 2020-11-06 00:07  猫头唔食鱼  阅读(477)  评论(0编辑  收藏  举报
import React, { Component } from "react";
import { View, Text } from "@tarojs/components";
export default class Index extends Component {
  constructor(props) {
    super(props);
    this.state = {
      list: [1, 2, 3, 4, 5, 6],
    };
  }
  render() {
    return (
      <View>
        <View>
          {this.state.list.map((a, i) => {
            return (
              <View
                key={i}
                style={{ backgroundColor: `rgba(0,0,0,0.${a})` }}
            >{a}</View>
            );
          })}
        </View>
      </View>
    );
  }
}

效果: