简体   繁体   English

多个自我内容页面

[英]Multiple self-content pages

I am trying to migrate Polymer 1 application to Polymer 2. My application comprises one "main" page index.html and one static file "multiple.html". 我正在尝试将Polymer 1应用程序迁移到Polymer2。我的应用程序包括一个“主”页面index.html和一个静态文件“ multiple.html”。

"index.html" is the first page delivered to client. “ index.html”是交付给客户端的第一页。 After users successfully log in to server via index.html , "index.html" creates the following tags inside itself: 用户通过index.html成功登录服务器后,“ index.html”会在其内部创建以下标记:

<a href="/m/1" target="_blank">menu item 1</a>
<a href="/m/2" target="_blank">menu item 2</a>
<a href="/m/3" target="_blank">menu item 3</a>

After users click on menu item N , server sends over the same file multiple.html . 用户单击菜单项N后 ,服务器将通过同一个文件发送文件multiple.html Browser than calls function document.URL to get 1 , 2 , or 3 as request parameters for data from server to build pages of different contents from the same static file "multiple.html". 浏览器比调用函数document.URL拿到1,2,3作为从服务器数据从同一个静态文件“multiple.html”构建不同内容的网页请求参数。 As such, the browser might now opens one main page and several "instances" of pages spawned from static file multiple.html . 因此,浏览器可能会立即打开一个主页和几个页面的“实例”从静态文件multiple.html催生。

Here is my problem: Polymer 2 allows only one "main" page, which is supposed to be specified in file bower.json . 这是我的问题:Polymer 2仅允许一个“主”页面,该页面应该在文件bower.json中指定。 How do I restructure my application so that I can run command 如何重组我的应用程序,以便可以运行命令

polymer build --js-minifiy --html-minify

and produce the correct compressed files, index.html and multiple.html in particular, in directory build/default ? 并在目录build / default中生成正确的压缩文件,尤其是index.htmlmultiple.html

Edit Please note that because files index.html and multiple.html share many files of custom elements, it is not a good idea to split this one application into two applications. 编辑请注意,由于文件index.htmlMultiple.html共享许多自定义元素文件,因此,将这个应用程序拆分为两个应用程序不是一个好主意。

Edit 2 Many thanks for your inputs! 编辑2非常感谢您的投入! I did not make my question specific enough. 我的问题不够具体。 I will follow the design pattern illustrated by Polymer Shop and try using Polymer element app-route . 我将遵循Polymer Shop所示的设计模式,并尝试使用Polymer元素app-route

You should provide a polymer.json file in the root of your app. 您应该在应用程序的根目录中提供一个polymer.json文件。

In there you can define multiple files. 您可以在其中定义多个文件。

{
  "entrypoint": "index.html",
  "fragments": [
    "multiple.html",
  ]
}

for more details see https://www.polymer-project.org/2.0/docs/tools/polymer-json 有关更多详细信息,请参见https://www.polymer-project.org/2.0/docs/tools/polymer-json

eg you can also provide the js minification and html minification there so you don't have to provide it on command line. 例如,您还可以在那里提供js最小化和html最小化,因此您不必在命令行上提供它。

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

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