有条件地将 javascript 文件包含在 xbl 中

发布于 2024-10-02 06:22:38 字数 153 浏览 0 评论 0 原文

我可以有条件地包含 javascript 文件和 css 文件吗?

这可以有条件地完成吗?

Can I conditionally include javascript file and css files.

<xbl:script src="/apps/xforms-sandbox/samples/myfile.js" />

Can this be done conditionally?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寒冷纷飞旳雪 2024-10-09 06:22:38

此时,在 Orbeon Forms 中,您无法有条件地包含带有 的脚本或带有 的 CSS。要包含动态资源,请在 : XBL 组件的 template>。如果可以使用静态资源,您应该:

  1. 避免重复 — 如果加载页面时组件有多个实例,则相同的 JavaScript 或 CSS 最终将在页面中包含多次。您可能会说:好吧,但无论如何,使用 时都是这种情况。是的,但这是一个错误,希望我们能尽快修复这个问题。
  2. 为了从自动最小化和组合中受益 - 我们是 计划自动组合并最小化 XBL 组件中的资源引用,就像我们对核心 XForms 引擎本身使用的资源所做的那样。如果您使用 ,当该功能进入代码库时,您将能够受益于该功能。

At this point, in Orbeon Forms, you can't conditionally include scripts with <xbl:script> or CSS with <xbl:style>. To include dynamic resources, use HTML the elements <xhtml:script> and <xhtml:style> you generate with XSTL, inside the <xbl:template> of your XBL component. If you can use static resource, you should:

  1. To avoid duplication — If you have multiple instances of your component when the page is loaded, then the same JavaScript or CSS will end up being included multiple times in the page. You might say: well, but this is the case anyway when using <xbl:script> and <xbl:style>. Yes, but this is a bug, which hopefully we'll get a chance to fix soon.
  2. To benefit from automatic minimization and combination — We are planning to automatically combine and minimize the resources references in XBL components, just like we do for resources used by the core XForms engine itself. You will be able to benefit from this feature when it lands in the codebase if you use <xbl:script> and <xbl:style>.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文