简体   繁体   English

根据 url 在单个页面上加载数据

[英]Load data on a single page based on the url

I have a single html file that I have linked to Firestore that I want to load public data on based on the URL (not url params).我有一个链接到 Firestore 的 html 文件,我想根据 URL(不是 url 参数)加载公共数据。

The url will be generated by the user from the slug parameter in my firestore:该 url 将由用户从我的 firestore 中的 slug 参数生成:

Domain.com/bobs-store (slug = bobs-store) Domain.com/bobs-store (slug = bobs-store)

Domain.com/sallys-boutique (slug = sallys-boutique) Domain.com/sallys-boutique (slug = sallys-boutique)

Domain.com/davidsgarage (slug = davidsgarage) Domain.com/davidsgarage (slug = davidsgarage)

Based on the url I want to load Firestore data (using the slug which I pull from the url).基于 url 我想加载 Firestore 数据(使用我从 url 中提取的 slug)。 I'm stumped on how to make the different urls all end up on the same index.html page regardless of the url without individual redirects.我很困惑如何使不同的 url 最终都出现在同一个 index.html 页面上,而不管没有单独重定向的 url。

Where you are stuck (mapping multiple URLs to a single page) seems to have very little to do with Firestore, but mostly depends on the provider where you host your HTML pages.您卡在哪里(将多个 URL 映射到单个页面)似乎与 Firestore 几乎没有关系,但主要取决于您托管 HTML 页面的提供商。

If you're using Firebase Hosting, have a look at how to configure rewrites .如果您使用 Firebase 托管,请查看 如何配置 rewrites For example, to map all URLs to the same index.html , that documentation shows this example:例如,要将所有 URL 映射到同一个index.html ,该文档显示了以下示例:

"hosting": {
  // ...

  // Serves index.html for requests to files or directories that do not exist
  "rewrites": [ {
    "source": "**",
    "destination": "/index.html"
  } ]
}

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

相关问题 使用JavaScript在URL中加载页面数据 - load data of page in URL using javascript Casper抓取加载在单个基于javascript的页面上的多页 - Casper scrape multipages that load on a single javascript based page 根据 url 查询参数返回页面上的数据 - Returning data on page based on url query params 纯JavaScript中基于URL的单页应用导航? - URL-based single page app nav in pure JavaScript? 根据URL中的定位标记激活页面加载上的链接点击 - Activate a link click on page load based on anchor tag in URL 尝试根据 URL 参数将 jpg 加载到页面上 - Trying to load a jpg onto a page based on a URL Parameter 如何根据URL和数据库数据加载不同的文本框? - How to load different textboxes based on url and database data? 在(无框架)基于 Javascript 的单页应用程序中,URL queryString 更新,但脚本无法解析更新后的 URL - In a (frameworkless) Javascript-based Single Page App, the URL queryString updates but the script fails to parse the updated URL 在整个页面上访问jplayer实例以基于用户点击加载数据 - accessing jplayer instance throughout page to load data based on user clicks 根据下拉菜单选择在另一页上的Divs中加载数据 - Load Data in Divs on another page based on dropdown form selections
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM