【问题标题】:Navigating around website with firebase hosting使用 Firebase 托管浏览网站
【发布时间】:2020-11-18 13:33:37
【问题描述】:

这个问题可能看起来很简单,但我正在尝试找到一种方法来浏览我在 firebase 主机上托管的网站。

所以我用这个屏幕创建了这个网站

现在,当用户单击工具栏中的“客厅”选项时,我想将它们导航到客厅屏幕,我环顾四周,阅读了 firebase 文档here,我可以将用户重定向到其他页面我的网站使用重写

所以我尝试在用户点击客厅选项时将 URL 更改为

“myAppDomain/LivingRoom”

然后我修复了 firebase.js 文件并将其添加到其中

"rewrites": [ {
  "source": "/LivingRoom",
  "destination": "/LivingRoom.html"
} ],

所以现在当用户单击按钮时,我只需将他的 URL 更改为“myWebSiteDomain.com/LivingRoom”。可悲的是,它似乎对我不起作用。

我只想在用户请求时将其引导至其他屏幕。如何做到这一点?

【问题讨论】:

    标签: firebase firebase-hosting


    【解决方案1】:

    重写用于更改特定页面的 URL。不将用户移动到不同的页面。您的重写所做的是将 URL 从 yoursite.com/LivingRoom.html 更改为 yoursite.com/LivingRoom 如果您的导航栏使用 button 标签,添加 onclick 属性并使用 window.location.href 重定向用户。

    <button onclick="window.location.href = "LivingRoom.html">Living Room</button>
    

    如果您的网站使用链接标签进行导航,请添加 href 属性。

    <a href="LivingRoom.html">Living Room</a>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-03
      • 2019-08-04
      • 1970-01-01
      • 2020-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多