Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 通过axios发送请求,然后动态构建html,或者通过nodejs应用程序中的res.render方法,哪个方法更有效_Javascript_Node.js_Web - Fatal编程技术网

Javascript 通过axios发送请求,然后动态构建html,或者通过nodejs应用程序中的res.render方法,哪个方法更有效

Javascript 通过axios发送请求,然后动态构建html,或者通过nodejs应用程序中的res.render方法,哪个方法更有效,javascript,node.js,web,Javascript,Node.js,Web,下面是我用来在页面上显示数据的代码,html是动态创建的,另一种方法是我查询数据库并使用res.render方法来呈现它,应该使用哪种方法 if (tBody) { return ( `<tr class="tr1"> <th class="th1"> Category Name </th> <th class="th1">De

下面是我用来在页面上显示数据的代码,html是动态创建的,另一种方法是我查询数据库并使用res.render方法来呈现它,应该使用哪种方法

if (tBody) {
    return (
      `<tr class="tr1">  


        <th class="th1"> Category Name </th> 
        <th class="th1">Delete </th> 


    </tr>` +
      getdata.data
        .map(function (wizard) {
          return `<tr class="td1">  <td class="th1"> ${wizard.categoryName}</td> 



            <td class="td1"><a class="delClass" onclick="removeCat(this)"  data-remove="${wizard._id}">Delete</a></td>
            
            </tr>`;
        })
        .join('')
    );
if(t车身){
返回(
`  
类别名称
删除
` +
getdata.data
.map(函数(向导){
返回`${wizard.categoryName}
删除
`;
})
.加入(“”)
);