简体   繁体   English

使用 Firebase 托管浏览网站

[英]Navigating around website with firebase hosting

this question might seem simple but I am trying to find a way to navigate around my website which I'm hosting on firebase host.这个问题可能看起来很简单,但我试图找到一种方法来浏览我在 firebase 主机上托管的网站。

so I've created this website with this screen所以我用这个屏幕创建了这个网站在此处输入图片说明

now when the user clicks on the "living room" option in the toolbar I want to navigate them to the living room screen, I looked around I read on the firebase documentation here that I can redirect users to other pages of my website using rewrites现在,当用户单击工具栏中的“客厅”选项时,我想将它们导航到客厅屏幕,我环顾四周,阅读了 此处的 firebase 文档,我可以使用重写将用户重定向到我网站的其他页面

so I tried to change the URL when the user clicks on the living room option to所以当用户点击客厅选项时,我尝试将 URL 更改为

"myAppDomain/LivingRoom" “我的应用程序域/客厅”

and then I fixed the firebase.js file and added this to it然后我修复了 firebase.js 文件并将其添加到其中

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

so for now when the user clicks on a button I just change his URL to "myWebSiteDomain.com/LivingRoom".所以现在当用户点击一个按钮时,我只是将他的 URL 更改为“myWebSiteDomain.com/LivingRoom”。 sadly it doesn't seem to work for me.可悲的是,它似乎对我不起作用。

I just want to direct users to other screens when they request it.我只想在用户请求时将其引导到其他屏幕。 How can achieve this?怎样才能做到这一点?

Rewrites are for changing the URL of a certain page.重写用于更改某个页面的 URL。 Not moving the user to a different page.不将用户移动到不同的页面。 What your rewrite did, is it changed the URL from yoursite.com/LivingRoom.html to yoursite.com/LivingRoom If your navigation bar uses the button tag , add the onclick attribute and use window.location.href to redirect the user.您的重写所做的是将 URL 从 yoursite.com/LivingRoom.html 更改为 yoursite.com/LivingRoom 如果您的导航栏使用按钮标记,请添加 onclick 属性并使用 window.location.href 重定向用户。

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

If your site uses link tags for the navigation, add the href attribute.如果您的站点使用链接标签进行导航,请添加 href 属性。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM