第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

我想以以下格式動(dòng)態(tài)添加數(shù)組中的元素

我想以以下格式動(dòng)態(tài)添加數(shù)組中的元素

梵蒂岡之花 2021-10-14 17:19:31
我有兩個(gè)數(shù)組,1 列和 2 行。我想按照代碼中所示動(dòng)態(tài)地將行數(shù)組數(shù)據(jù)添加到列數(shù)組。暫時(shí)我在這些數(shù)組中采用了硬編碼值,我有一個(gè)添加按鈕。實(shí)際上我想渲染具有下拉按鈕的 n*n 矩陣。我在添加按鈕上定義了一種方法,并使用 for 循環(huán)將列數(shù)組推送到行數(shù)組。import React, { Component } from "react";import './Table.css';export class Table extends Component {    constructor(props) {        super(props)        this.state = {            columns: ['state 1', 'state 2', 'state 3', 'state 4', 'state 5', ''],            emptyheader: [''],            rows: [                ['state 1', 'state 2', 'state 3', 'state 4', '', ''],                ['state 2', 'state 2', 'state 3', 'state 4', ' ', ''],                ['state 3', 'state 2', 'state 3', 'state 4', ' ', ''],                ['state 4', 'state 2', 'state 3', 'state 4', ' ', ''],                ['state 5', 'state 2', 'state 3', 'state 4', ' ', '']            ],            selectedTeam: ''        }        this.handleChange = this.handleChange.bind(this)    }    render() {        return (            <div>                <table align="center">                    <tbody>                        <tr>                            {this.state.emptyheader.map((emptyheader, i) =>                                <td >{emptyheader}</td>                            )}                            {this.state.columns.map((column, i) =>                                <td >{column}</td>                            )}                        </tr>export default Table;我想渲染 n*n 矩陣
查看完整描述

2 回答

?
蝴蝶刀刀

TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超8個(gè)贊

你能展示你的handleChange方法嗎


我認(rèn)為它應(yīng)該是這樣的


this.handleChange = (e) => {

    let { rows } = this.state;

    rows.push(newElement);

    this.setState(rows);

}


查看完整回答
反對(duì) 回復(fù) 2021-10-14
  • 2 回答
  • 0 關(guān)注
  • 172 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)