如何使用Express内的反应?

时间:2018-01-03 18:09:06

标签: node.js reactjs express

我有一个在expressjs / nodejs中开发的网站。我想为它添加一个reactjs模块。我在“客户端/构建”中添加了一个reactjs应用程序。在expressjs应用程序。 '客户机'声明为静态:

  

app.use(express.static(path.join(__ dirname,' client')));

我希望http://localhost:3002/build/可以正常工作,但事实并非如此。它显示一个没有错误的空白页面。开发人员工具中的网络选项卡显示已提取引用的CSS和JS文件,但未显示任何反应组件。我不明白为什么会这样。

更新

文件夹结构:

enter image description here

的index.html:

<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
      <meta name="theme-color" content="#000000">
      <link rel="manifest" href="/build/manifest.json">
      <link rel="shortcut icon" href="/build/favicon.ico">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
      <title>React App</title>
      <link href="/build/static/css/main.dd5f9b05.css" rel="stylesheet">
   </head>
   <body>
      <noscript>You need to enable JavaScript to run this app.</noscript>
      <div id="root"></div>
      <script type="text/javascript" src="/build/static/js/main.971e2482.js"></script>
   </body>
</html>

1 个答案:

答案 0 :(得分:0)

Arrays.sort(array, (o1, o2) -> o2.getValue() - o1.getValue());

我认为你必须先指定一个路径?