サルでもわかるWEBプログラミング

フリーソフトのみでホームページ作成

ユーザ用ツール

サイト用ツール


00.stencil:03.stencilの_propと_state


差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
00.stencil:03.stencilの_propと_state [2019/09/26] – [@state()の解説のリンク] adash33300.stencil:03.stencilの_propと_state [2019/09/26] (現在) – [@state()の解説のリンク] adash333
行 67: 行 67:
 https://www.joshmorony.com/building-a-pwa-with-stencil-storage-and-services/ では、 https://www.joshmorony.com/building-a-pwa-with-stencil-storage-and-services/ では、
  
-コンポーネント で、+コンポーネント  src/components/app-home/app-home.tsx で、
 <code> <code>
   @State() holdings: Holding[] = [];   @State() holdings: Holding[] = [];
 </code> </code>
-ることで、+、holdingsに@State()をつけることで、 
 +<code> 
 +  componentDidLoad() { 
 +    const router = document.querySelector("ion-router");
  
 +    // Refresh data every time view is entered
 +    router.addEventListener("ionRouteDidChange", async () => {
 +      const holdings = await Holdings.getHoldings();
 +      this.holdings = [...holdings];
 +    });
 +  }
 +</code>
 +により、ページのアドレスが変化するたびに、holdingsが再描画されて、表示されるものが最新のものになるようにしています。
  
  


00.stencil/03.stencilの_propと_state.1569462594.txt.gz · 最終更新: 2019/09/26 by adash333

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki