Polymer-paper-toast

提供:Dev Guides
移動先:案内検索

ポリマー-ペーパートースト

Paper-toastはアラート通知を提供し、特定の時間に1つの通知のみを許可します。 次のコマンドを実行してプロジェクトディレクトリにインストールすることにより、アプリケーションでこの要素を使用できます。

bower install --save PolymerElements/paper-toast

次の例では、Polymer.jsでpaper-toast要素の使用を指定しています。 indexlファイルを作成し、その中に次のコードを追加します。

<!doctype html>
<html>
   <head>
      <link rel = 'import' href = 'my-appl'>
   </head>

   <body>
      <my-app></my-app>
   </body>
</html>

次に、my-applファイルを開き、次のコードを含めます。

<link rel = 'import' href = 'bower_components/polymer/polymerl'>
<link rel = "import" href = "bower_components/paper-toast/paper-toastl">
<link rel = "import" href = "bower_components/paper-button/paper-buttonl">

<dom-module id = 'my-app'>
   <template>
      <style>
         #container {
            padding: 100px;
            border: 1px solid gray;
            width: 30%;
         }
      </style>

      <h3>Paper-Toast Example</h3>
      <div id = "container">
         <paper-button raised onclick = "toast.open()">Click Here</paper-button>
      </div>
      <paper-toast id = "toast" class = "fit-bottom" text = "Welcome to finddevguides.">
      </paper-toast>
   </template>

   <script>
      Polymer ({
         is: 'my-app', ready: function() {
            this.async(function() {
               toast.fitInto = container;
            });
         }
      });
   </script>
</dom-module>

出力

アプリケーションを実行するには、作成されたプロジェクトディレクトリに移動し、次のコマンドを実行します。

polymer serve

ここでブラウザを開き、 http://127.0.0.1:8081/ に移動します。 出力は次のようになります。

Polymer paper-toast1

[ここをクリック]ボタンをクリックすると、次のスクリーンショットが出力として表示されます。

Polymer paper-toast2