【问题标题】:How to setup html5 routing (client-side) on the loopback?如何在环回上设置 html5 路由(客户端)?
【发布时间】:2016-02-12 14:14:23
【问题描述】:

middleware.json(loopback)中应该写什么,操作html5模式,前端路由?

我可以使用如下所示的内容: app.all("/*", ...); 并返回我的 index.html 但是这个解决方案不利于环回。我可以覆盖我的 middleware.json 路由。 所以我需要一些解决方案如何在 middleware.json 中配置它

【问题讨论】:

    标签: angularjs node.js html routing loopbackjs


    【解决方案1】:

    这是来自文档,当您点击 / 时,他们添加了一个 root.js 路由来服务 API 的正常运行时间。只需将其更改为为您的 AngularJS index.html 提供服务即可。

    module.exports = function(server) {
      var router = server.loopback.Router();
      // could also use function that dynamically creates index.html, etc...
    
      router.get('/', <SEND index.html HERE>);
    
      server.use(router);
    };
    

    或者,您可以删除 server/boot/root.js(或重命名),然后按此处所述添加静态中间件:

    https://docs.strongloop.com/display/public/LB/Add+a+static+web+page

    服务器/中间件.json:

    ...
      "files": {
        "loopback#static": {
          "params": "$!../client"
        }
      },
    ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-17
      • 1970-01-01
      • 2022-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-03
      • 1970-01-01
      相关资源
      最近更新 更多