我的数据格式为下面提到的'SectionText',我可以根据该数据构建一个表。但是现在为了比较的目的,我有另一个数据作为'SectionTextTwo',格式与第一个相同,但现在我需要将两个数据合并到一个表中,如下所示。我很困惑如何将数据合并或组合成一个并将其显示为表格。任何投入都将受到高度赞赏。谢谢。
SectionText = Node\t MB-s (rec) \tMB-s (sent)\n172.22.1.91\t30.4549\t30.5486\n172.22.1.92\t30.736\t30.5485\n
var sectionRows = sectionText.split("\n");
{sectionRows.map((currRow) => {
if (currRow.length > 0) {
var fields = currRow.split("\t");
return (
<TableRow>
{fields.map((currField) => {
return (
<td>{currField}</td>
)
})}
</TableRow>
)
}
})}
Node MB-s (rec) MB-s (sent)
172.22.1.91 30.4549 30.5486
172.22.1.92 30.736 30.5485
SectionTextTwo = Node\t MB-s (rec) \tMB-s (sent)\n172.22.1.91\t30.4549\t30.5486\n172.22.1.92\t30.736\t30.5485\n
Required table :
Node MB-s (rec) MB-s (sent) Node MB-s (rec) MB-s (sent)
172.22.1.91 30.4549 30.5486 172.22.1.91 30.4549 30.5486
172.22.1.92 30.736 30.5485 172.22.1.92 30.736 30.5485
答案 0 :(得分:0)
我不太确定我是否完全理解了手头的问题。但我想你可以创建一个组件来构建表,例如:https://jsfiddle.net/69z2wepo/69404/
.text
.globl main
main:
la $a0,nreq # get value of n
li $v0,4
syscall
li $v0,5 # read value of n
syscall
# NOTE/BUG: add this
bltz $v0,exit # exit program on negative
move $a0,$v0 # place value n in $a0
jal fact # invoke fact
move $s0,$v0 # save value returned by facts
la $a0,ans # display
li $v0,4
syscall
move $a0,$s0
li $v0,1
syscall
# NOTE: add this
li $v0,4
la $a0,nl
syscall
j main
exit:
la $a0,cr # display closing
li $v0,4
syscall
li $v0,10 # exit
syscall
fact:
slti $t0,$a0,1 # test for n < 1
beq $t0,$zero,L1 # if n >= 1, go to L1
li $v0,1 # return 1
jr $ra # return to instruction after jal
L1:
addi $sp,$sp,-8 # adjust stack for 2 items
sw $ra,4($sp) # save the return address
sw $a0,0($sp) # save the argument n
addi $a0,$a0,-1 # n >= 1; argument gets (n – 1)
jal fact # call fact with (n – 1)
lw $a0,0($sp) # return from jal: restore argument n
lw $ra,4($sp) # restore the return address
addi $sp,$sp,8 # adjust stack pointer to pop 2 items
mul $v0,$a0,$v0 # return n * fact (n – 1)
jr $ra # return to the caller
.data
nreq: .asciiz "Enter a value for n (or negative to exit): "
ans: .asciiz "Value returned is "
nl: .asciiz "\n"
cr: .asciiz "\nThanks for testing!\n"
首先,您首先要创建一个组件,它将从构建数组的逻辑中抽象出来,只关注数据的呈现。然后,您可以使用它来传递格式化数据。
如果您想要两个表,则只需渲染该组件两次。如果需要单个表,则合并除第一行以外的数组并调用表组件。