如何动态生成表中的行?

时间:2016-06-15 16:18:49

标签: reactjs

我有

var model =[{
      name:  "Reg",
      value: "Reg"
    },{
      name:  "26.0000",
      value: "26.0000"
    }];

...

    generateRows(){
        var jsxResult = (
          <tr className="performRowStyle">
            {
                for(var i=0, rowCount = model.length; i < rowCount; i++ ) {
                    var thisRow = model[i];
                    console.log("columnData.name = " + thisRow.name + "columnData.value = " + thisRow.value);
                    jsxResult += (
                      <td className="performColumnStyle">
                         <span className="performColumnDataStyle">{thisRow.value}</span>
                      </td>
                    );
                }
            }
          </tr>
        );

       return jsxResult;
}

Webpack报告模块构建失败。它拒绝了我在jsxResult中放置的大部分JavaScript。这有效,但没有做任何有用的事情:

generateRows(){
    var jsxResult = (
      <tr className="performRowStyle">
        {
            this.test()

        }
      </tr>
    );

    return jsxResult;
  },

为什么我收到错误?如何动态生成此数据?

0 个答案:

没有答案