1

我有一个 Aurelia CLI 应用程序,并且我还使用 npm 安装了 admin-lte。问题是它没有正确加载。这是因为 Admin LTE 使用 jQuery DOM 就绪事件,并期望在那一刻事情在 DOM 中。但是,如果我在 app.html 中声明所有布局 html,则不会发生任何事情,因为稍后会附加内容(我的猜测)。

我创建了一个模拟问题的要点。我想我可以在 app.js 中使用附加的钩子并做一些事情,但我不确定是什么。

https://gist.run/?id=e4521c1fb38ec82bffd6a0e4fd8b1da6

如您所见,plugin.js 在 index.html 中被引用,就像我在应用程序中引用 Admin LTE javascripts 一样。div 不会更改,因为它是在 plugin.js 中的脚本运行之后到达的。

这是我真正的应用程序的主体:

<body aurelia-app="main" class="hold-transition skin-blue sidebar-mini">
    <script src="scripts/vendor-bundle.js" data-main="aurelia-bootstrapper"></script>
    <!-- REQUIRED JS SCRIPTS -->

    <!-- jQuery 2.2.3 -->
    <script src="node_modules/admin-lte/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <!-- Bootstrap 3.3.6 -->
    <script src="node_modules/admin-lte/bootstrap/js/bootstrap.min.js"></script>
    <!-- AdminLTE App -->
    <script src="node_modules/admin-lte/dist/js/app.js"></script>
  </body>

我真正需要的是确保$(function () {...})inadmin-lte/dist/js/app.js运行。也许你可以强制 jQuery 重新运行这个函数?

4

1 回答 1

1

在我的 app.js 中,我可以使用附加的函数并调用一个函数来修复布局:

export class App {
    attached(){
        $.AdminLTE.layout.fix();
    }
}

在这里找到信息

于 2016-09-02T08:13:57.660 回答