【问题标题】:How do I deliver static html pages with vaadin router (client side)?如何使用 vaadin 路由器(客户端)提供静态 html 页面?
【发布时间】:2020-07-01 15:24:23
【问题描述】:

vaadin-router 是一个小型客户端 javascript 路由器。如何交付任意数量的静态 html 页面?

【问题讨论】:

    标签: javascript vaadin-router


    【解决方案1】:

    demo 包含如何将router-ignore 作为属性添加到链接的示例

    <a href="/users" router-ignore>Users</a>
    

    以及如何将与特定通道匹配的所有文件作为特殊路径传递的示例

    // this would be the first route in the router config:
    var specialRoute = 
        {
            path: '/external/(.*)',
            action: (ctx, commands) => {
            window.location.pathname = ctx.pathname;
        }
     };
    

    所以要通过路由器传递所有 html 文件,我们可以使用:

    var routeStaticHtmlFiles = 
    {
        path: '(.*)\.html',
        action: (ctx, commands) => {
            window.location.pathname = ctx.pathname;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-06
      • 1970-01-01
      • 2018-02-05
      • 2012-06-19
      • 2019-09-22
      • 1970-01-01
      • 2012-09-21
      • 1970-01-01
      相关资源
      最近更新 更多