javascript - 为每个表条

时间:2018-02-08 07:30:08

标签: javascript jquery

我正在构建一个包含某些测试结果的应用。 结果保存在云DB中。我需要为此DB中的每个条目创建一个页面,该页面将显示当前条目的特定结果。每个条目的模板都是相同的,只需要每次都更改其中的数据。

我该怎么办? 非常感谢, 塔尔

1 个答案:

答案 0 :(得分:0)

如果您不想复制您的网页, 你应该使用带快递(https://expressjs.com/)的模板引擎来管理你的路线。

示例:

    // app.js --> running on your server
    app.set('view engine', "YOUR_TEMPLATE_ENGINE"); // jade, pug, twig ...

    // index here corresponds to your index. html file
    app.get("/one", (req, res) => {
      res.render("index", { message: 'Hello there 1 !'});
    });
    app.get("/two", (req, res) => {
      res.render("index", { message: "Hello there 2 !"});
    });