聚合物中的手动引导 [英] Manual bootstrap in Polymer

查看:72
本文介绍了聚合物中的手动引导的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种强制性的方式以 Angular bootstrap 的方式引导Polymer?

Is there an imperative way to bootstrap Polymer, in the style of Angular bootstrap?

文档提供有关单个元素生命周期的详细信息,但没有任何内容关于框架本身.

The docs give details about individual elements lifecycle, but nothing about the framework itself.

我正在寻找一种使Polymer与requirejs协调一致的方法,并且我需要强制单点进入我的应用程序.如果我可以从 requirejs数据主域中引导聚合物,那我就是好.

I'm looking for a way to reconcile Polymer with requirejs and I need to force a single point of entry into my app. If I can bootstrap Polymer from within the requirejs data-main, I'm good.

相关材料:
-使用Polymer和requirejs
- Require.js加载所有资源应用,包括Polymer
-聚合物+ requirejs:属性为聚合物升级元素之前绑定数据
-在Google组上需要js + polymer线程
- polymer + requirejs要领

related material:
- Working with Polymer and requirejs
- Require.js to load all resources for an app, including Polymer
- Polymer + requirejs: Attributes on were data bound prior to Polymer upgrading the element
- requirejs+polymer thread on google group
- polymer+requirejs gist

推荐答案

我已经找到一种手动触发我的应用进行引导的简单方法(至少适用于单页应用),这也是您可以执行的操作:

I've figured out a simple way to manually trigger my app to bootstrap (at least it works for single page app), here's how you can do it too:

  • 请勿从index.html或直接从索引导入的任何其他页面导入您的任何custom-element.html.您的polymer-ready事件应立即触发,但不会加载任何自定义元素.这可能需要您另外采取以避免FOUC的步骤不会.
  • 要引导应用程序时,请使用 polymer.import 辅助函数可以开始工作.如果您具有相互导入的元素层次结构,则只需手动导入顶级元素,其他元素将通过html导入进行导入.如果要动态导入应用程序的各个部分,可以在不同的时间使用不同的元素重复此操作.
  • Don't import any of your custom-element.html from the index.html or any other page directly imported from the index. Your polymer-ready event should fire straight away but none of your custom elements will be loaded. This may require additional steps on your part to avoid FOUC and what not.
  • When you want to bootstrap your app, use the polymer.import helper function to kick things off. If you have a hierarchy of elements importing each other, you only need to manually import the top-level elements, the others will be imported through html imports. You can repeat this with different elements at different times if you want to import parts of your app dynamically.

这篇关于聚合物中的手动引导的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆