首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用纸质对话聚合物元件?

如何使用纸质对话聚合物元件?
EN

Stack Overflow用户
提问于 2014-11-19 19:00:12
回答 3查看 11.7K关注 0票数 9

我通过添加开始和结束标记<paper-dialog><p>This is it</p></paper-dialog>来使用元素,但它没有显示出来。我是否需要在它上面添加一些脚本,以便在某些事件上触发它?或者有其他方法可以让它变得可见?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-11-20 00:09:46

对话框本身是自动隐藏的。你通常用一个按钮来切换它。例如,为对话框提供一个id="dialog",并将按钮设置为on-tap="toggleDialog",如下所示

代码语言:javascript
复制
toggleDialog: () => {
    this.$.dialog.toggle();
},
票数 17
EN

Stack Overflow用户

发布于 2018-02-13 16:51:56

代码语言:javascript
复制
<base href="https://polygit.org/polymer+polymer+v1.11.2/components/" />
<script src="webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="polymer/polymer.html" />
<link rel="import" href="paper-dialog/paper-dialog.html" />
<link rel="import" href="paper-input/paper-input.html" />
<link rel="import" href="paper-button/paper-button.html" />

<!--Here, we use a input field to give input to the dialog box-->  
<paper-input label="Name" id="username" always-float-label allowed-pattern="[a-zA-Z]" value={{username}} required error-message="User Name Required"></paper-input>

   <!--The button is used to submit the values-->

   <paper-button class="green" on-tap="validatedetails">Submit</paper-button>

   <!--Dialog is usually hidden. So by using id we can call the dialog box-->
   <div>
     <paper-dialog id="userdetails">

     <!--This section is used to fetch the input from the input-field and display on the dialog using one-way data binding-->

     <h2>User Information</h2>
       <p>[[username]]</p>

       <div class="buttons">

       <!--This button is used to close the dialog-->


       <paper-button dialog-dismiss style="color: #0B746E" on-tap="cleardata">CLOSE</paper-button>
     </div>
   </paper-dialog>
 </div>

 <script>
   Polymer({
     is: 'paper-dialog',
     properties: {
       username: {
         type: String,
       },

       <!--This function is used to call the dialog-->

       validatedetails: function() {
         this.$.userdetails.open();
       },
      });
  </script>
票数 0
EN

Stack Overflow用户

发布于 2018-10-17 23:39:49

对于聚合物3.0,我创建了我的paper-dialog来从列表中删除一个带有标题、描述和两个按钮的项目。

代码语言:javascript
复制
<paper-dialog id="dialogDelete" >
    <h2>Delete</h2>
    <p>Are yout sure you want to delete this catalog?.</p>
    <div class="buttons">
        <paper-button dialog-dismiss>Cancel</paper-button>
        <paper-button dialog-confirm autofocus on-tap="_attempDeleteCatalog">Delete</paper-button>
    </div>
</paper-dialog>

要调用这个对话框,我唯一要做的就是在函数中通过id调用它,如下所示。

代码语言:javascript
复制
this.$.dialogDelete.open()

我希望它能帮上忙。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27015173

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档