簡體   English   中英

Angular5:在加載頁面之前加載微調器

[英]Angular5: loading spinner before load page

有沒有辦法加載加載微調器

[`https://plnkr.co/edit/yhA0AwY9gzd0JsxhDouz?p=preview`][1]

而不是在事件(點擊),但在應用程序加載時開始加載頁面,我知道加載模塊的棘手的bcs指令不能在應用程序之前加載,但如果有人這樣做可能以其他方式。 謝謝。

您是否嘗試將微調器放在服務器端的HTML頁面(即index.hbs或您正在使用的任何模板引擎)之間?

例如:

<my-app> 
  spinner code
</my-app>

它會在加載時顯示它。

如果你看 - > http://akveo.com/ngx-admin/ ,你可以看到你正在尋找的效果。

他們實現它的方法是將代碼放在index.html文件中的<my-app> Loading... </myapp>

這是他們的回購鏈接 - > https://github.com/akveo/ngx-admin ,你正在尋找的index.html的正文部分如下所示:

<body>
  <ngx-app>Loading...</ngx-app>

  <style>@-webkit-keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@-moz-keyframes spin{0%{-moz-transform:rotate(0)}100%{-moz-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.spinner{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1003;background: #000000;overflow:hidden}  .spinner div:first-child{display:block;position:relative;left:50%;top:50%;width:150px;height:150px;margin:-75px 0 0 -75px;border-radius:50%;box-shadow:0 3px 3px 0 rgba(255,56,106,1);transform:translate3d(0,0,0);animation:spin 2s linear infinite}  .spinner div:first-child:after,.spinner div:first-child:before{content:'';position:absolute;border-radius:50%}  .spinner div:first-child:before{top:5px;left:5px;right:5px;bottom:5px;box-shadow:0 3px 3px 0 rgb(255, 228, 32);-webkit-animation:spin 3s linear infinite;animation:spin 3s linear infinite}  .spinner div:first-child:after{top:15px;left:15px;right:15px;bottom:15px;box-shadow:0 3px 3px 0 rgba(61, 175, 255,1);animation:spin 1.5s linear infinite}</style>
  <div id="nb-global-spinner" class="spinner">
    <div class="blob blob-0"></div>
    <div class="blob blob-1"></div>
    <div class="blob blob-2"></div>
    <div class="blob blob-3"></div>
    <div class="blob blob-4"></div>
    <div class="blob blob-5"></div>
  </div>

</body>

我只使用CSS制作了這個plunkr

在您的情況下,您將無法執行此操作,因為它是一個Angular組件。 您需要加載您的應用程序才能使用您的組件!

您可以做的只是更改我的CSS(和HTML)代碼以滿足您的需求。

玩得開心 !

//Mandatory plunkr code

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM