gpt4 book ai didi

javascript - 如何处理 $(document).foundation() 调用和 WebPack?

转载 作者:数据小太阳 更新时间:2023-10-29 05:38:03 25 4
gpt4 key购买 nike

根据基金会的documentation :

After you have included the Foundation JavaScript, just add a simple call to initialize all plugins on your page.

We recommend that you initialize Foundation at the end of the page .

<script>
$(document).foundation();
</script>

我的应用使用 WebPack,因此模块加载是异步
这意味着正文底部的经典脚本会在 ui-view 被模板填充之前运行。 (使用 Angular)。

如果我将脚本放在底部,DOM 会在被 Foundation 的脚本解析之前填充,从而不会对 Foundation 的所有组件行为产生任何影响。

你有过同样的经历吗?

我不想在每个 Controller 的模板中触发 $(document).foundation();

最佳答案

您应该在 document.ready 事件或 window.load 上执行 $(document).foundation()。但最好的解决方案是模块明智地启动 Foundation JS。

例如,创建 Accordion var elem = new Foundation.Accordion(element, options);

关于javascript - 如何处理 $(document).foundation() 调用和 WebPack?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35014779/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com